Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mamba equivalent of `conda shell.bash hook`

Tags:

shell

conda

mamba

I'd like to use mamba activate [env] in a shell script.

What would be the equivalent of conda shell.bash hook? I've tried mamba shell.bash hook and mamba shell hook -s posix.

like image 950
dimid Avatar asked Sep 07 '25 08:09

dimid


1 Answers

You can initialize mamba in your shell with the command mamba init.

However, you may want to run the hook subcommand in a non-interactive bash script where you need to activate an environment. There's no equivalent of conda shell.bash hook for mamba. To initialize mamba "on the fly", you must source the file $MAMBA_ROOT_PREFIX/etc/profile.d/mamba.sh, for example: source ~/miniconda3/etc/profile.d/mamba.sh.

You want to do this after initializing conda with eval "$(conda shell.bash hook)".

like image 153
bepoli Avatar answered Sep 11 '25 07:09

bepoli