How to remove (base) from terminal prompt after updating conda

安稳与你 提交于 2019-12-29 17:45:10

问题


After updating miniconda3, whenever I open a terminal it shows "(base)" in front of my username and host.

In this answer post https://askubuntu.com/a/1113206/315699 it was suggested to use

conda config --set changeps1 False

To remove it.

But that would remove the indication for any conda environment. I would like to remove it only for the base one, so that I can maintain it always active and have access to its python and installed packages without having to always see this (base) taking up space.


回答1:


Use the base env's activation hook

For each env, any scripts in the etc/conda/activate.d directory will be executed post-activation (likewise etc/conda/deactivate.d scripts for deactivation). If you add a script to remove the (base), similar to @ewindes suggestion, you'll get the behavior you desire.

I had to create this directory for base, which is just the root of your Anaconda/Miniconda folder. E.g.,

mkdir -p miniconda3/etc/conda/activate.d

Then made a simple file in there (e.g., remove_base_ps1.sh) with one line:

PS1="$(echo "$PS1" | sed 's/(base) //') "

Launching a new shell then does not show (base), and deactivating out of nested envs also takes care of the PS1 change.

Note: You must add quotes around $PS1 if you want to preserve ending spaces.




回答2:


That's because conda's base environment is activated on startup.

To set the auto_activate_base parameter to false, type:

conda config --set auto_activate_base false




回答3:


You could add a command to your .bashrc to remove the "(base)" string from PS1:

PS1=$(echo $PS1 | sed 's/(base)//')


来源:https://stackoverflow.com/questions/55171696/how-to-remove-base-from-terminal-prompt-after-updating-conda

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!