diff --git a/plugins/available/virtualenv.plugin.bash b/plugins/available/virtualenv.plugin.bash old mode 100644 new mode 100755 index 331f6080..b200901f --- a/plugins/available/virtualenv.plugin.bash +++ b/plugins/available/virtualenv.plugin.bash @@ -5,22 +5,42 @@ about-plugin 'virtualenvwrapper helper functions' [[ `which virtualenvwrapper.sh` ]] && . virtualenvwrapper.sh +# default python version - use python2 to pick +# up Homebrew version if applicable +if hash brew 2>/dev/null && hash python2 2>/dev/null; then + PYVER="--python=`command -v python2`" +fi function mkvenv { about 'create a new virtualenv for this directory' group 'virtualenv' cwd=`basename \`pwd\`` - mkvirtualenv $cwd + mkvirtualenv $PYVER $cwd } +function mkvenv3 { + about 'create a new virtualenv for this directory using python3' + group 'virtualenv' + + PYVER="--python=`command -v python3`" + mkvenv +} function mkvbranch { about 'create a new virtualenv for the current branch' group 'virtualenv' scm_prompt_info >/dev/null 2>&1 - mkvirtualenv "$(basename `pwd`)@$SCM_BRANCH" + mkvirtualenv $PYVER "$(basename `pwd`)@$SCM_BRANCH" +} + +function mkvbranch3 { + about 'create a new virtualenv for this directory using python3' + group 'virtualenv' + + PYVER="--python=`command -v python3`" + mkvbranch } function wovbranch { @@ -37,3 +57,18 @@ function wovenv { workon "$(basename `pwd`)" } + +function mkve { + about 'create a new virtualenv with the specified name' + group 'virtualenv' + + mkvirtualenv $PYVER $1 +} + +function mkve3 { + about 'create a new virtualenv with the specified name using python3' + group 'virtualenv' + + PYVER="--python=`command -v python3`" + mkve $1 +}