Skip to content

Commit 0879d03

Browse files
committed
Fix the problem with lazy completion for bash
To fix lazy completion bash needs to be instructed to restart completion after virtualenvwrapper loads the real implementation. Code 124 means exactly that: retry completion. See `man bash`.
1 parent 5bae977 commit 0879d03

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

virtualenvwrapper_lazy.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,16 @@ function $venvw_name {
4444
# Set up completion functions to virtualenvwrapper_load
4545
function virtualenvwrapper_setup_lazy_completion {
4646
if [ -n "$BASH" ] ; then
47-
complete -o nospace -F virtualenvwrapper_load $(echo ${_VIRTUALENVWRAPPER_API})
47+
function virtualenvwrapper_lazy_load {
48+
virtualenvwrapper_load
49+
return 124
50+
}
51+
complete -o nospace -F virtualenvwrapper_lazy_load $(echo ${_VIRTUALENVWRAPPER_API})
4852
elif [ -n "$ZSH_VERSION" ] ; then
4953
compctl -K virtualenvwrapper_load $(echo ${_VIRTUALENVWRAPPER_API})
5054
fi
5155
}
5256

5357
virtualenvwrapper_setup_lazy_loader
54-
# Does not really work. Cannot be reset in zsh to fallback to files (e.g. mkvirtualenv).
55-
# It also needs a second invocation, because the first one only sets up the real completion.
58+
# Cannot be reset in zsh to fallback to files (e.g. mkvirtualenv).
5659
virtualenvwrapper_setup_lazy_completion

0 commit comments

Comments
 (0)