Created
September 5, 2019 14:52
-
-
Save peterk87/a0c761da672cacde58a8d9c3fd575888 to your computer and use it in GitHub Desktop.
Basic Conda Bash completions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_conda(){ | |
if (( ${#COMP_WORDS[@]} < 3 )); then | |
COMPREPLY=( $(compgen -W "activate deactivate clean config create help info init install list package remove uninstall run search update upgrade env -h --help -V --version" -- $2 ) ); | |
else | |
if [[ $3 == "activate" ]]; then | |
local cur="${COMP_WORDS[COMP_CWORD]}"; | |
local envs=( $(ls "$HOME/miniconda3/envs/") ); | |
COMPREPLY=( $(compgen -W "${envs[*]}" -- $cur) ); | |
elif [[ $3 == "env" ]]; then | |
local cur="${COMP_WORDS[COMP_CWORD]}"; | |
COMPREPLY=( $(compgen -W "create export list remove update -h --help" -- $cur) ); | |
fi | |
fi | |
} | |
complete -F _conda conda; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copy-paste into
~/.bash_completion
(or~/.bashrc
) to enable basic bash completions for Conda. Assumes that you have Miniconda3 installed at~/miniconda3
.conda activate <TAB>
for locally installed Conda envs (directories in~/miniconda3/envs/
).conda <TAB>
andconda env <TAB>
)