Skip to content

Conversation

@IanButterworth
Copy link
Member

@IanButterworth IanButterworth commented Jul 28, 2021

Adds pkg> activate - and Pkg.activate(prev=true) to switch to the previously active environment. Matches cd - and git checkout - behavior.

There was a suggestion to instead do this with a blank pkg> activate but for me at least that's muscle memory for getting to the @x.x env.

(Pkg) pkg> activate --temp
  Activating new project at `/var/folders/_6/1yf6sj0950vcg4t91m9ltb5w0000gn/T/jl_d8KZ5n`

(jl_d8KZ5n) pkg> activate -
  Activating project at `~/Documents/GitHub/Pkg.jl`

(Pkg) pkg> activate -
  Activating new project at `/var/folders/_6/1yf6sj0950vcg4t91m9ltb5w0000gn/T/jl_d8KZ5n`

(jl_d8KZ5n) pkg> activate
  Activating project at `~/.julia/environments/v1.8`

(@v1.8) pkg> activate -
  Activating new project at `/var/folders/_6/1yf6sj0950vcg4t91m9ltb5w0000gn/T/jl_d8KZ5n`

(jl_d8KZ5n) pkg> activate -
  Activating project at `~/.julia/environments/v1.8`

(@v1.8) pkg> activate .
  Activating project at `~/Documents/GitHub/Pkg.jl`

(Pkg) pkg> activate -
  Activating project at `~/.julia/environments/v1.8`

(@v1.8) pkg> activate -
  Activating project at `~/Documents/GitHub/Pkg.jl`

(Pkg) pkg>

Note that the previously used environment is looked up from the manifest usage file on startup, which is quick for my 6KB usage file.
And this should be quick generally given the usage file is now minimized with #2661

julia> @btime Pkg.get_last_used_env_from_usage()
  85.058 μs (910 allocations: 55.55 KiB)
"/Users/ian/Documents/GitHub/Pkg.jl"

Will add tests if this goes forward

@KristofferC
Copy link
Member

I like this but I think using the previous session is a bit overkill, or? That seems like it would never be used.

@IanButterworth
Copy link
Member Author

I just pushed a tweak on where the try-catch is, but happy to remove the previous session stuff. I'll leave it a few days

@KristofferC
Copy link
Member

Could perhaps use a test and then should be ready to go.

@IanButterworth IanButterworth merged commit 33fa5d7 into JuliaLang:master Jul 30, 2021
@IanButterworth IanButterworth deleted the ib/activate_previous branch February 2, 2022 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants