diff --git a/src/activate.jl b/src/activate.jl index ffd5529..e0fa0e9 100644 --- a/src/activate.jl +++ b/src/activate.jl @@ -2,7 +2,6 @@ function activate(config::Config; dir::AbstractString="", name::AbstractString=" init(config) pg = PlaygroundConfig(config, dir, name) - set_envs(pg) prompt = config.default_prompt @@ -12,24 +11,28 @@ function activate(config::Config; dir::AbstractString="", name::AbstractString=" found = get_playground_name(config, pg.root_path) if found != "" prompt = replace(prompt, "playground", found) + pg.name = found end end - run_shell(prompt) + set_envs(pg) + run_shell(pg, prompt) end @windows_only begin - function run_shell(prompt) + function run_shell(config, prompt) run(`cmd /K prompt $(prompt)`) end end @unix_only begin - function run_shell(prompt) + function run_shell(config, prompt) ENV["PS1"] = prompt - if haskey(ENV, "SHELL") + if haskey(ENV, "SHELL") && contains(ENV["SHELL"], "fish") + run(`$(ENV["SHELL"]) -i`) + elseif haskey(ENV, "SHELL") # Try and setup the new shell as close to the user's default shell as possible. usr_rc = joinpath(homedir(), "." * basename(ENV["SHELL"]) * "rc") pg_rc = joinpath(dirname(ENV["JULIA_PKGDIR"]), basename(ENV["SHELL"]) * "rc") diff --git a/src/config.jl b/src/config.jl index 4176032..1f63d2f 100644 --- a/src/config.jl +++ b/src/config.jl @@ -24,6 +24,7 @@ type Config dir::DirectoryStructure default_playground_path::AbstractString default_prompt::AbstractString + default_shell::AbstractString default_git_address::AbstractString default_git_revision::AbstractString isolated_shell_history::Bool @@ -34,6 +35,7 @@ type Config DirectoryStructure(kwargs["root"]), abspath(kwargs["default_playground_path"]), kwargs["default_prompt"], + haskey(kwargs, "default_shell") ? kwargs["default_shell"] : "", kwargs["default_git_address"], kwargs["default_git_revision"], kwargs["isolated_shell_history"], @@ -44,22 +46,26 @@ end type PlaygroundConfig + name::AbstractString root_path::AbstractString log_path::AbstractString bin_path::AbstractString pkg_path::AbstractString julia_path::AbstractString + default_shell::AbstractString isolated_shell_history::Bool isolated_julia_history::Bool function PlaygroundConfig(config::Config, dir::AbstractString, name) root_path = get_playground_dir(config, dir, name) new( + name, root_path, joinpath(root_path, "log"), joinpath(root_path, "bin"), joinpath(root_path, "packages"), joinpath(root_path, "bin", "julia"), + config.default_shell, config.isolated_shell_history, config.isolated_julia_history ) @@ -104,8 +110,13 @@ end function set_envs(pg::PlaygroundConfig) ENV["PATH"] = "$(pg.bin_path):" * ENV["PATH"] + ENV["PLAYGROUND_ENV"] = pg.name == "" ? basename(pg.root_path) : pg.name ENV["JULIA_PKGDIR"] = pg.pkg_path + if pg.default_shell != "" + ENV["SHELL"] = pg.default_shell + end + if pg.isolated_julia_history ENV["JULIA_HISTORY"] = joinpath(pg.root_path, ".julia_history") end diff --git a/src/constants.jl b/src/constants.jl index 9d76f94..3233daf 100644 --- a/src/constants.jl +++ b/src/constants.jl @@ -18,6 +18,10 @@ default_playground_path: .playground # Default shell prompt when you activate a playground. default_prompt: \"$(escape_string(DEFAULT_PROMPT))\" +# Uncomment below to change the default shell. Otherwise the SHELL +# Environment variable will be used. +# default_shell: /usr/local/bin/fish + # Default git settings when using install build default_git_address: \"https://github.com/JuliaLang/julia.git\" default_git_revision: master @@ -25,4 +29,4 @@ default_git_revision: master # Allows you to isolate shell and julia history to each playground. isolated_shell_history: true isolated_julia_history: true -""" \ No newline at end of file +"""