Skip to content

Instantly share code, notes, and snippets.

@jybaek jybaek/conda.sh
Created Jun 11, 2019

Embed
What would you like to do?
conda bash_completion
#!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
@jybaek

This comment has been minimized.

Copy link
Owner Author

jybaek commented Jun 11, 2019

Place it under the /etc/bash_completion.d/ directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.