@@ -36,7 +36,7 @@ export WORKON_HOME
3636function virtualenvwrapper_verify_workon_home () {
3737 if [ ! -d "$WORKON_HOME" ]
3838 then
39- echo "ERROR: Virtual environments directory '$WORKON_HOME' does not exist."
39+ echo "ERROR: Virtual environments directory '$WORKON_HOME' does not exist." >&2
4040 return 1
4141 fi
4242 return 0
@@ -47,7 +47,7 @@ function virtualenvwrapper_verify_workon_environment () {
4747 typeset env_name="$1"
4848 if [ ! -d "$WORKON_HOME/$env_name" ]
4949 then
50- echo "ERROR: Environment '$env_name' does not exist. Create it with 'mkvirtualenv $env_name'."
50+ echo "ERROR: Environment '$env_name' does not exist. Create it with 'mkvirtualenv $env_name'." >&2
5151 return 1
5252 fi
5353 return 0
@@ -57,7 +57,7 @@ function virtualenvwrapper_verify_workon_environment () {
5757function virtualenvwrapper_verify_active_environment () {
5858 if [ ! -n "${VIRTUAL_ENV}" ] || [ ! -d "${VIRTUAL_ENV}" ]
5959 then
60- echo "ERROR: no virtualenv active, or active virtualenv is missing"
60+ echo "ERROR: no virtualenv active, or active virtualenv is missing" >&2
6161 return 1
6262 fi
6363 return 0
@@ -106,14 +106,14 @@ function rmvirtualenv () {
106106 virtualenvwrapper_verify_workon_home || return 1
107107 if [ "$env_name" = "" ]
108108 then
109- echo "Please specify an enviroment."
109+ echo "Please specify an enviroment." >&2
110110 return 1
111111 fi
112112 env_dir="$WORKON_HOME/$env_name"
113113 if [ "$VIRTUAL_ENV" = "$env_dir" ]
114114 then
115- echo "ERROR: You cannot remove the active environment ('$env_name')."
116- echo "Either switch to another environment, or run 'deactivate'."
115+ echo "ERROR: You cannot remove the active environment ('$env_name')." >&2
116+ echo "Either switch to another environment, or run 'deactivate'." >&2
117117 return 1
118118 fi
119119 virtualenvwrapper_run_hook "$WORKON_HOME/prermvirtualenv" "$env_dir"
@@ -149,7 +149,7 @@ function workon () {
149149 activate="$WORKON_HOME/$env_name/bin/activate"
150150 if [ ! -f "$activate" ]
151151 then
152- echo "ERROR: Environment '$WORKON_HOME/$env_name' does not contain an activate script."
152+ echo "ERROR: Environment '$WORKON_HOME/$env_name' does not contain an activate script." >&2
153153 return 1
154154 fi
155155
@@ -206,6 +206,13 @@ if [ -n "$BASH" ] ; then
206206 COMPREPLY=( $(compgen -W "`virtualenvwrapper_show_workon_options`" -- ${cur}) )
207207 }
208208
209+ _cdvirtualenv_complete ()
210+ {
211+ local cur="$2"
212+ # COMPREPLY=( $(compgen -d -- "${VIRTUAL_ENV}/${cur}" | sed -e "s@${VIRTUAL_ENV}/@@" ) )
213+ COMPREPLY=( $(cdvirtualenv && compgen -d -- "${cur}" ) )
214+ }
215+ complete -o nospace -F _cdvirtualenv_complete -S/ cdvirtualenv
209216 complete -o default -o nospace -F _virtualenvs workon
210217 complete -o default -o nospace -F _virtualenvs rmvirtualenv
211218elif [ -n "$ZSH_VERSION" ] ; then
@@ -233,7 +240,7 @@ function add2virtualenv () {
233240
234241 if [ ! -d "${site_packages}" ]
235242 then
236- echo "ERROR: currently-active virtualenv does not appear to have a site-packages directory"
243+ echo "ERROR: currently-active virtualenv does not appear to have a site-packages directory" >&2
237244 return 1
238245 fi
239246
0 commit comments