Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 969
Homero Esmeraldo Avatar asked Mar 14 '19 20:03

Homero Esmeraldo


People also ask

How do I get out of conda base?

To exit the virtual environment, use the command conda deactivate . If you run conda info --envs again, there is no * in front of env_name . That's because the env_name virtual environment is no longer active.

Why does my Mac terminal say base?

That's the "base" environment from Anaconda or Miniconda. It means the Python environment from conda is enabled by default.

What is conda base?

Conda has a default environment called base that include a Python installation and some core system libraries and dependencies of Conda. It is a “best practice” to avoid installing additional packages into your base software environment.


2 Answers

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


Edited 2021/09/09:

If you are facing the exact same situation as the OP, that you are using conda to manage environments, and wanted to make (base) environment looks no different to system environment in terminal, check @merv 's answer for the procedures. Note that the prompt string is stored in a certain special variable, depending on the shell you are using, so check the documentation of your shell if it does not work for you.

If you want to use the system environment and not using conda at all, my original answer was the solution for you.

Thanks to @merv and @Neinstein for pointing out in the comments.

like image 93
Yokissa Avatar answered Sep 28 '22 06:09

Yokissa


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) //') " 

If you are using zsh, use this instead.

PROMPT=$(echo $PROMPT | 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.

like image 25
merv Avatar answered Sep 28 '22 04:09

merv