Merge pull request #341 from lucasnad27/master
Added pyenv-virtualenv plugin
This commit is contained in:
61
plugins/available/pyenv-virtualenv.plugin.bash
Normal file
61
plugins/available/pyenv-virtualenv.plugin.bash
Normal file
@@ -0,0 +1,61 @@
|
||||
# make sure virtualenvwrapper is enabled if available
|
||||
|
||||
cite about-plugin
|
||||
about-plugin 'pyenv-virtualenvwrapper helper functions'
|
||||
|
||||
export PYENV_VIRTUALENVWRAPPER_PREFER_PYVENV="true"
|
||||
|
||||
[[ `which pyenv` ]] && eval "$(pyenv init -)"
|
||||
[[ `which pyenv-virtualenvwrapper` ]] && eval "$(pyenv virtualenvwrapper)"
|
||||
|
||||
# Activate autoenv
|
||||
source /usr/local/opt/autoenv/activate.sh
|
||||
|
||||
function mkpvenv {
|
||||
about 'create a new virtualenv for this directory'
|
||||
group 'pyenv-virtualenv'
|
||||
|
||||
cwd=`basename \`pwd\``
|
||||
eval "touch .env"
|
||||
eval "echo \"#!/bin/bash\" >> .env"
|
||||
eval "echo \"if [ \\\`basename \\\$(pwd)\\\` == \\\"$cwd\\\" ]; then \"eval \"wopvenv\"\"; fi\" >> .env"
|
||||
mkvirtualenv --distribute $cwd
|
||||
}
|
||||
|
||||
function mkpvbranch {
|
||||
about 'create a new virtualenv for the current branch'
|
||||
group 'pyenv-virtualenv'
|
||||
|
||||
mkvirtualenv --distribute "$(basename `pwd`)@$SCM_BRANCH"
|
||||
}
|
||||
|
||||
function wopvbranch {
|
||||
about 'sets workon branch'
|
||||
group 'pyenv-virtualenv'
|
||||
|
||||
workon "$(basename `pwd`)@$SCM_BRANCH"
|
||||
}
|
||||
|
||||
function wopvenv {
|
||||
about 'works on the virtualenv for this directory'
|
||||
group 'virtualenv'
|
||||
|
||||
workon "$(basename `pwd`)"
|
||||
}
|
||||
|
||||
function rmpvenv {
|
||||
about 'removes virtualenv for this directory'
|
||||
group 'virtualenv'
|
||||
|
||||
eval "deactivate"
|
||||
rmvirtualenv "$(basename `pwd`)"
|
||||
eval "rm .env"
|
||||
}
|
||||
|
||||
function rmpvenvbranch {
|
||||
about 'removes virtualenv for this directory'
|
||||
group 'virtualenv'
|
||||
|
||||
eval "deactivate"
|
||||
rmvirtualenv "$(basename `pwd`)@$SCM_BRANCH"
|
||||
}
|
||||
@@ -1,14 +1,10 @@
|
||||
cite about-plugin
|
||||
about-plugin 'load pyenv, if you are using it'
|
||||
|
||||
export PYENV_ROOT="$HOME/.pyenv"
|
||||
export PATH="$PYENV_ROOT/bin:$PATH"
|
||||
[[ `which pyenv` ]] && eval "$(pyenv init -)"
|
||||
export PYENV_PATH=`which pyenv`
|
||||
export PATH="$PYENV_PATH:$PATH"
|
||||
|
||||
#Load pyenv virtualenv if the virtualenv plugin is installed.
|
||||
if pyenv virtualenv-init - &> /dev/null; then
|
||||
eval "$(pyenv virtualenv-init -)"
|
||||
fi
|
||||
[[ `which pyenv` ]] && eval "$(pyenv init -)"
|
||||
|
||||
# Load the auto-completion script if pyenv was loaded.
|
||||
[[ -e $PYENV_ROOT/completions/pyenv.bash ]] && source $PYENV_ROOT/completions/pyenv.bash
|
||||
|
||||
Reference in New Issue
Block a user