# Repl\_history depending on current working directory

**URL:** <https://discourse.julialang.org/t/repl-history-depending-on-current-working-directory/52890>\
**Category:** New to Julia\
**Created:** [January 5, 2021, 5:47pm UTC](https://discourse.julialang.org/t/repl-history-depending-on-current-working-directory/52890 "2021-01-05T17:47:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![circonflexe](https://avatars.discourse-cdn.com/v4/letter/c/c57346/32.png) [@circonflexe](https://discourse.julialang.org/u/circonflexe)\
**Post date:** [January 5, 2021, 5:47pm UTC](https://discourse.julialang.org/t/repl-history-depending-on-current-working-directory/52890/1 "2021-01-05T17:47:08Z")

</div>

So I am working concurrently on two separate projects, let us call them `A` and `B`. When I am in the working directory of project `A`, anything in `repl_history.jl` that is connected to project `B` is basically clutter, and vice-versa. So starting a new work session in one project requires going faaaar back in history to find what I was doing.

I was going to ask the following question here, but I found an answer in the meantime; I’m leaving both of them here in case it is useful to someone.

Is there a way to have REPL history depend on current directory?

The answer is: since Julia looks at the `JULIA_HISTORY` environment variable, we could set this one dependent on the presence of a given file in the current directory; e.g. (in the shell; something similar might be cooked in a Julia init file as well):

```
julia() {
  hist_jl=./.repl_history.jl
  [-f $hist_jl] && extra="JULIA_HISTORY=$hist_jl"
  env $extra =julia "$@"
}

```

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [January 5, 2021, 6:26pm UTC](https://discourse.julialang.org/t/repl-history-depending-on-current-working-directory/52890/2 "2021-01-05T18:26:39Z")

</div>

Diary.jl does something like this

[https://github.com/dalum/Diary.jl](https://github.com/dalum/Diary.jl)

---

<div class="post-metadata">

**Author:** ![rfourquet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rfourquet/32/3610_2.png) [@rfourquet](https://discourse.julialang.org/u/rfourquet)\
**Post date:** [January 6, 2021, 11:07am UTC](https://discourse.julialang.org/t/repl-history-depending-on-current-working-directory/52890/3 "2021-01-06T11:07:46Z")

</div>

[`direnv`](https://direnv.net/) can be used to make it seamless, e.g. I’ve in some of my project folders an `.envrc` file with the following content:

```bash
export JULIA_PROJECT=@.
export JULIA_HISTORY="$HOME/.julia/logs/repl_histories/$(basename $(pwd)).jl"

```

---

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [January 6, 2021, 12:34pm UTC](https://discourse.julialang.org/t/repl-history-depending-on-current-working-directory/52890/4 "2021-01-06T12:34:47Z")

</div>

[https://github.com/JuliaLang/julia/issues/34205](https://github.com/JuliaLang/julia/issues/34205)
