Published 11th October 2008
I started migrating my projects to virtualenv and found virtualenvwrapper to be a really useful script—it helps keeping the environments manageable.
However, there was one thing I missed in virtualenvwrapper
(especially when using the workon command all day long): bash completion.
So, here's a script which will solve this small problem:
_virtualenvs()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "`ls $WORKON_HOME`" -- ${cur}) )
}
complete -o default -o nospace -F _virtualenvs workon
complete -o default -o nospace -F _virtualenvs rmvirtualenv
The choices are generated from the directory listing of your
$WORKON_HOME directory.