From 180db373e7e9a4777104b763a60c5380c5f3828f Mon Sep 17 00:00:00 2001 From: Scott Drennan Date: Sat, 15 Mar 2014 11:47:40 -0700 Subject: [PATCH] virtualenv - commands to support both python2 and python3 --- plugins/available/virtualenv.plugin.bash | 39 ++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) mode change 100644 => 100755 plugins/available/virtualenv.plugin.bash 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 +}