Skip to content

Instantly share code, notes, and snippets.

@bcl
Created July 19, 2018 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcl/7fee1f639a9b491c3df830cbcc4e1287 to your computer and use it in GitHub Desktop.
Save bcl/7fee1f639a9b491c3df830cbcc4e1287 to your computer and use it in GitHub Desktop.
tab complete virtualenvs
VENV_DIR=${VENV_DIR:-~/.local/virtualenv}
_envon()
{
local venvs cur
# Get the list of environments
venvs=$(for x in $VENV_DIR/*; do basename "$x" ; done)
cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "${venvs}" -- ${cur}) )
return 0
}
envon()
{
source $VENV_DIR/$1/bin/activate
}
complete -F _envon envon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment