65
65
VIRTUALENVWRAPPER_ENV_BIN_DIR=" Scripts"
66
66
fi
67
67
68
- virtualenvwrapper_derive_workon_home () {
68
+ function virtualenvwrapper_derive_workon_home {
69
69
typeset workon_home_dir=" $WORKON_HOME "
70
70
71
71
# Make sure there is a default value for WORKON_HOME.
@@ -103,7 +103,7 @@ virtualenvwrapper_derive_workon_home() {
103
103
# create it if it does not
104
104
# seperate from creating the files in it because this used to just error
105
105
# and maybe other things rely on the dir existing before that happens.
106
- virtualenvwrapper_verify_workon_home () {
106
+ function virtualenvwrapper_verify_workon_home {
107
107
RC=0
108
108
if [ ! -d " $WORKON_HOME /" ]
109
109
then
@@ -120,7 +120,7 @@ virtualenvwrapper_verify_workon_home () {
120
120
# HOOK_VERBOSE_OPTION="-q"
121
121
122
122
# Expects 1 argument, the suffix for the new file.
123
- virtualenvwrapper_tempfile () {
123
+ function virtualenvwrapper_tempfile {
124
124
# Note: the 'X's must come last
125
125
typeset suffix=${1:- hook}
126
126
typeset file=" ` \m ktemp -t virtualenvwrapper-$suffix -XXXXXXXXXX` "
@@ -135,7 +135,7 @@ virtualenvwrapper_tempfile () {
135
135
}
136
136
137
137
# Run the hooks
138
- virtualenvwrapper_run_hook () {
138
+ function virtualenvwrapper_run_hook {
139
139
typeset hook_script=" $( virtualenvwrapper_tempfile ${1} -hook) "
140
140
if [ -z " $hook_script " ]
141
141
then
@@ -165,7 +165,7 @@ virtualenvwrapper_run_hook () {
165
165
166
166
# Set up tab completion. (Adapted from Arthur Koziel's version at
167
167
# http://arthurkoziel.com/2008/10/11/virtualenvwrapper-bash-completion/)
168
- virtualenvwrapper_setup_tab_completion () {
168
+ function virtualenvwrapper_setup_tab_completion {
169
169
if [ -n " $BASH " ] ; then
170
170
_virtualenvs () {
171
171
local cur=" ${COMP_WORDS[COMP_CWORD]} "
@@ -202,7 +202,7 @@ virtualenvwrapper_setup_tab_completion () {
202
202
}
203
203
204
204
# Set up virtualenvwrapper properly
205
- virtualenvwrapper_initialize () {
205
+ function virtualenvwrapper_initialize {
206
206
export WORKON_HOME=" $( virtualenvwrapper_derive_workon_home) "
207
207
208
208
virtualenvwrapper_verify_workon_home -q || return 1
@@ -232,7 +232,7 @@ virtualenvwrapper_initialize () {
232
232
233
233
234
234
# Verify that virtualenv is installed and visible
235
- virtualenvwrapper_verify_virtualenv () {
235
+ function virtualenvwrapper_verify_virtualenv {
236
236
typeset venv=$( \w hich " $VIRTUALENVWRAPPER_VIRTUALENV " | (unset GREP_OPTIONS; \g rep -v " not found" ))
237
237
if [ " $venv " = " " ]
238
238
then
@@ -248,7 +248,7 @@ virtualenvwrapper_verify_virtualenv () {
248
248
}
249
249
250
250
# Verify that the requested environment exists
251
- virtualenvwrapper_verify_workon_environment () {
251
+ function virtualenvwrapper_verify_workon_environment {
252
252
typeset env_name=" $1 "
253
253
if [ ! -d " $WORKON_HOME /$env_name " ]
254
254
then
@@ -259,7 +259,7 @@ virtualenvwrapper_verify_workon_environment () {
259
259
}
260
260
261
261
# Verify that the active environment exists
262
- virtualenvwrapper_verify_active_environment () {
262
+ function virtualenvwrapper_verify_active_environment {
263
263
if [ ! -n " ${VIRTUAL_ENV} " ] || [ ! -d " ${VIRTUAL_ENV} " ]
264
264
then
265
265
echo " ERROR: no virtualenv active, or active virtualenv is missing" >&2
@@ -273,7 +273,7 @@ virtualenvwrapper_verify_active_environment () {
273
273
# Usage: mkvirtualenv [options] ENVNAME
274
274
# (where the options are passed directly to virtualenv)
275
275
#
276
- mkvirtualenv () {
276
+ function mkvirtualenv {
277
277
eval " envname=\$ $# "
278
278
virtualenvwrapper_verify_workon_home || return 1
279
279
virtualenvwrapper_verify_virtualenv || return 1
@@ -297,7 +297,7 @@ mkvirtualenv () {
297
297
}
298
298
299
299
# Remove an environment, in the WORKON_HOME.
300
- rmvirtualenv () {
300
+ function rmvirtualenv {
301
301
typeset env_name=" $1 "
302
302
virtualenvwrapper_verify_workon_home || return 1
303
303
if [ " $env_name " = " " ]
@@ -330,7 +330,7 @@ rmvirtualenv () {
330
330
}
331
331
332
332
# List the available environments.
333
- virtualenvwrapper_show_workon_options () {
333
+ function virtualenvwrapper_show_workon_options {
334
334
virtualenvwrapper_verify_workon_home || return 1
335
335
# NOTE: DO NOT use ls here because colorized versions spew control characters
336
336
# into the output list.
@@ -340,7 +340,7 @@ virtualenvwrapper_show_workon_options () {
340
340
# (\cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort
341
341
}
342
342
343
- _lsvirtualenv_usage () {
343
+ function _lsvirtualenv_usage {
344
344
echo " lsvirtualenv [-blh]"
345
345
echo " -b -- brief mode"
346
346
echo " -l -- long mode"
@@ -350,7 +350,7 @@ _lsvirtualenv_usage () {
350
350
# List virtual environments
351
351
#
352
352
# Usage: lsvirtualenv [-l]
353
- lsvirtualenv () {
353
+ function lsvirtualenv {
354
354
355
355
typeset long_mode=true
356
356
if command -v " getopts" & > /dev/null
@@ -403,7 +403,7 @@ lsvirtualenv () {
403
403
# Show details of a virtualenv
404
404
#
405
405
# Usage: showvirtualenv [env]
406
- showvirtualenv () {
406
+ function showvirtualenv {
407
407
typeset env_name=" $1 "
408
408
if [ -z " $env_name " ]
409
409
then
@@ -424,7 +424,7 @@ showvirtualenv () {
424
424
#
425
425
# Usage: workon [environment_name]
426
426
#
427
- workon () {
427
+ function workon {
428
428
typeset env_name=" $1 "
429
429
if [ " $env_name " = " " ]
430
430
then
@@ -492,15 +492,15 @@ workon () {
492
492
493
493
494
494
# Prints the Python version string for the current interpreter.
495
- virtualenvwrapper_get_python_version () {
495
+ function virtualenvwrapper_get_python_version {
496
496
# Uses the Python from the virtualenv because we're trying to
497
497
# determine the version installed there so we can build
498
498
# up the path to the site-packages directory.
499
499
python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.
500
500
}
501
501
502
502
# Prints the path to the site-packages directory for the current environment.
503
- virtualenvwrapper_get_site_packages_dir () {
503
+ function virtualenvwrapper_get_site_packages_dir {
504
504
echo " $VIRTUAL_ENV /lib/python` virtualenvwrapper_get_python_version` /site-packages"
505
505
}
506
506
@@ -515,7 +515,7 @@ virtualenvwrapper_get_site_packages_dir () {
515
515
# "virtualenv_path_extensions.pth" inside the virtualenv's
516
516
# site-packages directory; if this file does not exist, it will be
517
517
# created first.
518
- add2virtualenv () {
518
+ function add2virtualenv {
519
519
520
520
virtualenvwrapper_verify_workon_home || return 1
521
521
virtualenvwrapper_verify_active_environment || return 1
@@ -557,23 +557,23 @@ add2virtualenv () {
557
557
558
558
# Does a ``cd`` to the site-packages directory of the currently-active
559
559
# virtualenv.
560
- cdsitepackages () {
560
+ function cdsitepackages {
561
561
virtualenvwrapper_verify_workon_home || return 1
562
562
virtualenvwrapper_verify_active_environment || return 1
563
563
typeset site_packages=" ` virtualenvwrapper_get_site_packages_dir` "
564
564
\c d " $site_packages " /$1
565
565
}
566
566
567
567
# Does a ``cd`` to the root of the currently-active virtualenv.
568
- cdvirtualenv () {
568
+ function cdvirtualenv {
569
569
virtualenvwrapper_verify_workon_home || return 1
570
570
virtualenvwrapper_verify_active_environment || return 1
571
571
\c d $VIRTUAL_ENV /$1
572
572
}
573
573
574
574
# Shows the content of the site-packages directory of the currently-active
575
575
# virtualenv
576
- lssitepackages () {
576
+ function lssitepackages {
577
577
virtualenvwrapper_verify_workon_home || return 1
578
578
virtualenvwrapper_verify_active_environment || return 1
579
579
typeset site_packages=" ` virtualenvwrapper_get_site_packages_dir` "
@@ -590,7 +590,7 @@ lssitepackages () {
590
590
591
591
# Toggles the currently-active virtualenv between having and not having
592
592
# access to the global site-packages.
593
- toggleglobalsitepackages () {
593
+ function toggleglobalsitepackages {
594
594
virtualenvwrapper_verify_workon_home || return 1
595
595
virtualenvwrapper_verify_active_environment || return 1
596
596
typeset no_global_site_packages_file=" ` virtualenvwrapper_get_site_packages_dir` /../no-global-site-packages.txt"
@@ -604,7 +604,7 @@ toggleglobalsitepackages () {
604
604
}
605
605
606
606
# Duplicate the named virtualenv to make a new one.
607
- cpvirtualenv () {
607
+ function cpvirtualenv {
608
608
typeset env_name=" $1 "
609
609
if [ " $env_name " = " " ]
610
610
then
0 commit comments