Skip to content

Instantly share code, notes, and snippets.

@mikecharles
Last active May 23, 2016 15:41
Show Gist options
  • Select an option

  • Save mikecharles/aab0eef95599d1cd3eaee611fdf47eb7 to your computer and use it in GitHub Desktop.

Select an option

Save mikecharles/aab0eef95599d1cd3eaee611fdf47eb7 to your computer and use it in GitHub Desktop.
Bash completion script for source activating a conda environment
_complete_source_activate_conda()
{
if [ ${COMP_WORDS[COMP_CWORD-1]} != "activate" ] ; then
return 0
fi
local cur env_list
cur=${COMP_WORDS[COMP_CWORD]}
env_list=$(conda env list | sed '1d;2d;$d' | awk {'print $1'})
COMPREPLY=( $(compgen -W "${env_list[@]}" -- "$cur") )
}
complete -F _complete_source_activate_conda source
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment