It sounds you want to bring back the function definition at the REPL prompt and be able to edit it. If so, Ctrl-R
will serve you well for this. Ctrl-R
followed by foo(
will search in your REPL history for lines that contain foo(
and display the latest one it finds. You can press Ctrl-R again to repeat the search to find an occurrence before that. Once you find the method definition you want, just pressing any arrow key will bring you out of the search mode and let you edit the definition. (If you use OhMyREPL.jl, you get a nice menu when you press Ctrl-R, which makes this process even easier and more intuitive.)
If you do want the function definition as an output, CodeTracking.jl has a @code_string
macro for that.
julia> using CodeTracking
julia> foo(a,b) = a + b
foo (generic function with 1 method)
julia> @code_string foo(1, 2)
"foo(a,b) = a + b"
It’s meant to be a lightweight subset of Revise.jl functionality, so should be fine to load in your startup.jl if you need this often.