# History of the current (temporary) environment

**URL:** <https://discourse.julialang.org/t/history-of-the-current-temporary-environment/79067>\
**Category:** General Usage\
**Created:** [April 5, 2022, 6:45pm UTC](https://discourse.julialang.org/t/history-of-the-current-temporary-environment/79067 "2022-04-05T18:45:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [April 5, 2022, 6:45pm UTC](https://discourse.julialang.org/t/history-of-the-current-temporary-environment/79067/1 "2022-04-05T18:45:20Z")

</div>

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:

```julia
(@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):
 0.1690167981382612
 0.5608462436140107
 0.43529751740046885

```

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.

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [April 5, 2022, 8:02pm UTC](https://discourse.julialang.org/t/history-of-the-current-temporary-environment/79067/2 "2022-04-05T20:02:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Post date:** [April 5, 2022, 8:11pm UTC](https://discourse.julialang.org/t/history-of-the-current-temporary-environment/79067/3 "2022-04-05T20:11:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [April 6, 2022, 5:26am UTC](https://discourse.julialang.org/t/history-of-the-current-temporary-environment/79067/4 "2022-04-06T05:26:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [April 6, 2022, 11:57am UTC](https://discourse.julialang.org/t/history-of-the-current-temporary-environment/79067/5 "2022-04-06T11:57:28Z")

</div>

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.
