Created
July 19, 2018 03:13
-
-
Save bcl/7fee1f639a9b491c3df830cbcc4e1287 to your computer and use it in GitHub Desktop.
tab complete virtualenvs
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
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