Created
June 11, 2019 00:52
-
-
Save jybaek/0611faa6816f5438c524f241af8897a8 to your computer and use it in GitHub Desktop.
conda bash_completion
This file contains 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
#!bash | |
_conda() | |
{ | |
local cur prev | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
opt="activate deactivate" | |
envs=$(conda info --envs 2>/dev/null | grep -v '^#' | awk '{print $1}') | |
case "${prev}" in | |
activate) | |
COMPREPLY=( $( compgen -W "${envs}" -- "$cur" ) ) | |
return 0 | |
;; | |
esac | |
if [ "$prev" == "conda" ];then | |
COMPREPLY=( $( compgen -W "$opt" -- "$cur" ) ) | |
fi | |
return 0 | |
} | |
complete -F _conda conda |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Place it under the
/etc/bash_completion.d/
directory.