Skip to content

Instantly share code, notes, and snippets.

@jhidding
Created July 19, 2017 15:20
Show Gist options
  • Save jhidding/078b6a8aa6cef9ab7ed7b916b59ebbb1 to your computer and use it in GitHub Desktop.
Save jhidding/078b6a8aa6cef9ab7ed7b916b59ebbb1 to your computer and use it in GitHub Desktop.
A bash command for creating and activating Python virtual envs
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