When I run:
source activate /anaconda2/envs/myEnv
it shows the entire directory of this conda environment in my prompt (on iterm2) as so:
(/Users/billy/anaconda2/envs/myEnv)billy@mbp:~/projects
Is this a way to shorten this, so that it just shows the name of the conda environment and not the entire directory? For example as:
(myEnv)billy@mbp:~/projects
Thanks.
You can try the following:
Make sure that /anaconda2/envs
is listed in the section envs_dirs
in the output for the command:
$ conda config --show
If it is not present, you can add it like this:
$ conda config --add envs_dirs /anaconda2/envs
Then, activate the environment like this:
$ source activate myEnv
Example:
(root) ~/condaexpts ❯❯❯ conda create -yp /tmp/miniconda2/myEnv
Fetching package metadata .......
.Solving package specifications: .
Package plan for installation in environment /tmp/miniconda2/myEnv:
The following empty environments will be CREATED:
/tmp/miniconda2/myEnv
#
# To activate this environment, use:
# > source activate /tmp/miniconda2/myEnv
#
# To deactivate this environment, use:
# > source deactivate /tmp/miniconda2/myEnv
#
(root) ~/condaexpts ❯❯❯ conda config --add envs_dirs /tmp/miniconda2
(root) ~/condaexpts ❯❯❯ source activate myEnv
(myEnv) ~/condaexpts ❯❯❯
You can set the env_prompt
option in the config file, see Specifying a location for an environment.
One option is conda config --set env_prompt '({name})'
or you can edit the .condarc
in your home directory. Just add env_prompt: '({name})'
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With