History of the current (temporary) environment

Is it possible to fetch (or copy to a file) the history of the commands of specifically the current temporary environment? Such as something like:

(@v1.7) pkg> activate --temp
  Activating new project at `/tmp/jl_gaocNs`

julia> using StaticArrays

julia> x = rand(SVector{3,Float64})
3-element SVector{3, Float64} with indices SOneTo(3):

the .julia/logs/repl_history.jl contains that information, but in a mixed order if two Julia sections are run at the same time, and no indication about the section or environment associated to each command.


If you know in advance you’ll want it, you can supply --history_file="filename.log" to the julia call


Interesting! Can this also be set/changed during a session?
Is it possible to use an IOBuffer instead of a file?

1 Like

I was wrong, I just saw that somewhere and made an ass out of u and me. --history_file is a boolean option.

And looking into the code of REPL.jl, it seems pretty difficult to roll your own. It’s stored as an IOStream in the REPL.Prompt object in the julia_prompt field of the Repl.ModalInterface that is stored in a REPL.LineEditREPL object that represents the currently running REPL, so if you can get that out somehow you could potentially backtrace and replace it with your own IOStream, but I have found no methods to do any of it. Sounds like a feature request.


Packages like Revise seem to assume complete control over the REPL (even changing the color of the prompt and anticipating all commands). So I guess this can be done. I will take a look at these packages to see how they work.