Created
July 19, 2017 15:20
-
-
Save jhidding/078b6a8aa6cef9ab7ed7b916b59ebbb1 to your computer and use it in GitHub Desktop.
A bash command for creating and activating Python virtual envs
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
export WORKON_PATH="${HOME}/.local/share/workon" | |
function workon() { | |
source ${WORKON_PATH}/${1}/bin/activate | |
} | |
function create-python3-env() { | |
py3-virtualenv ${WORKON_PATH}/${1} | |
} | |
_workon() | |
{ | |
local cur prev opts | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
opts="$(ls ${WORKON_PATH})" | |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | |
return 0 | |
} | |
complete -o nospace -F _workon workon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment