Conda Prompt Customization
Since Conda v4.6.0 there has been the env_prompt
configuration option to provide for customization of the PS1 change. Here is the description:
$ conda config --describe env_prompt
# # env_prompt (str)
# # Template for prompt modification based on the active environment.
# # Currently supported template variables are '{prefix}', '{name}', and
# # '{default_env}'. '{prefix}' is the absolute path to the active
# # environment. '{name}' is the basename of the active environment
# # prefix. '{default_env}' holds the value of '{name}' if the active
# # environment is a conda named environment ('-n' flag), or otherwise
# # holds the value of '{prefix}'. Templating uses python's str.format()
# # method.
# #
# env_prompt: '({default_env}) '
One option that would help with your case would be to just use the {name}
variable
conda config --set env_prompt '({name}) '
which will show only the env's folder name. E.g., your example would be
(venv) user@machine: ~/path/to/environment/$
Note, this will make it so that when the base env is active the prompt will show (anaconda3)
instead of (base)
; otherwise, the other named envs should appear as usual.
If you really can't stand that, you could run basename {default_env}
to get the same result as {name}
on unnamed envs and still retain base
. That is,
conda config --set env_prompt '(\$(basename {default_env})) '