File tree Expand file tree Collapse file tree 3 files changed +34
-3
lines changed Expand file tree Collapse file tree 3 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 13
13
- Fix documentation for ``add2virtualenv `` to show the correct name
14
14
for the file containing the new path entry. (contributed by
15
15
:bbuser: `rvoicilas `)
16
+ - Fix problem with ``virtualenvwrapper_show_workon_options `` under
17
+ zsh with ``chpwd `` functions that produce output. (:bbissue: `153 `)
16
18
17
19
.. _stevedore : http://pypi.python.org/pypi/stevedore
18
20
Original file line number Diff line number Diff line change @@ -83,6 +83,22 @@ test_virtualenvwrapper_show_workon_options_grep_options () {
83
83
rm -f " $WORKON_HOME /link_env"
84
84
}
85
85
86
+ test_virtualenvwrapper_show_workon_options_chpwd () {
87
+ # https://bitbucket.org/dhellmann/virtualenvwrapper/issue/153
88
+ function chpwd {
89
+ local SEARCH=' '
90
+ local REPLACE=' %20'
91
+ local PWD_URL=" file://$HOSTNAME ${PWD// $SEARCH / $REPLACE } "
92
+ printf ' \e]7;%s\a' " $PWD_URL "
93
+ echo -n " \033]0;${HOST// .* } :$USER \007"
94
+ }
95
+ mkdir " $WORKON_HOME /not_env"
96
+ envs=$( virtualenvwrapper_show_workon_options | tr ' \n' ' ' )
97
+ assertSame " env1 env2 " " $envs "
98
+ rmdir " $WORKON_HOME /not_env"
99
+ rm -f " $WORKON_HOME /link_env"
100
+ }
101
+
86
102
test_virtualenvwrapper_show_workon_options_no_envs () {
87
103
old_home=" $WORKON_HOME "
88
104
export WORKON_HOME=${TMPDIR:-/ tmp} /$$
Original file line number Diff line number Diff line change @@ -502,10 +502,23 @@ function rmvirtualenv {
502
502
# List the available environments.
503
503
function virtualenvwrapper_show_workon_options {
504
504
virtualenvwrapper_verify_workon_home || return 1
505
- # NOTE: DO NOT use ls here because colorized versions spew control characters
506
- # into the output list.
505
+ # NOTE: DO NOT use ls or cd here because colorized versions spew control
506
+ # characters into the output list.
507
507
# echo seems a little faster than find, even with -depth 3.
508
- (virtualenvwrapper_cd " $WORKON_HOME " ; for f in * /$VIRTUALENVWRAPPER_ENV_BIN_DIR /activate; do echo $f ; done) 2> /dev/null | command \s ed ' s|^\./||' | command \s ed " s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR /activate||" | command \s ort | (unset GREP_OPTIONS; command \e grep -v ' ^\*$' )
508
+ #
509
+ # 1. Look for environments by finding the activate scripts.
510
+ # Use a subshell so we can suppress the message printed
511
+ # by zsh if the glob pattern fails to match any files.
512
+ # 2. Strip the WORKON_HOME prefix from each name.
513
+ # 3. Strip the bindir/activate script suffix.
514
+ # 4. Format the output to show one name on a line.
515
+ # 5. Eliminate any lines with * on them because that means there
516
+ # were no envs.
517
+ (echo $WORKON_HOME /* /$VIRTUALENVWRAPPER_ENV_BIN_DIR /activate) 2> /dev/null \
518
+ | command \s ed " s|$WORKON_HOME /||g" \
519
+ | command \s ed " s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR /activate||g" \
520
+ | command \f mt -w 1 \
521
+ | (unset GREP_OPTIONS; command \e grep -v ' ^\*$' ) 2> /dev/null
509
522
}
510
523
511
524
function _lsvirtualenv_usage {
You can’t perform that action at this time.
0 commit comments