Added better support for pyenv, virtualenvwrapper, and autoenv

working in concert with one another.
Features added:
- Added a pyenv-virtualenv plugin which creates virtual environments
  using the current pyenv python version
- `cd` into a directory that has a virtual environment already created
  and autoenv will automatically activate that environment
- Current virtual environment is displayed in command prompt
pull/341/head
Luke Culbertson 2014-09-25 17:23:53 -07:00
parent 4d2a8fe62b
commit a0f89bc1f8
3 changed files with 62 additions and 3 deletions

View File

@ -0,0 +1,58 @@
# make sure virtualenvwrapper is enabled if available
cite about-plugin
about-plugin 'pyenv-virtualenvwrapper helper functions'
export PYENV_VIRTUALENVWRAPPER_PREFER_PYVENV="true"
# Activate autoenv
source /usr/local/opt/autoenv/activate.sh
function mkenv {
about 'create a new virtualenv for this directory'
group 'pyenv-virtualenv'
eval "touch .env"
eval "echo \"#!/bin/bash\" >> .env"
eval "echo \"eval \"wovenv\"\" >> .env"
cwd=`basename \`pwd\``
mkvirtualenv --distribute $cwd
}
function mkvbranch {
about 'create a new virtualenv for the current branch'
group 'pyenv-virtualenv'
mkvirtualenv --distribute "$(basename `pwd`)@$SCM_BRANCH"
}
function wovbranch {
about 'sets workon branch'
group 'pyenv-virtualenv'
workon "$(basename `pwd`)@$SCM_BRANCH"
}
function wovenv {
about 'works on the virtualenv for this directory'
group 'virtualenv'
workon "$(basename `pwd`)"
}
function rmenv {
about 'removes virtualenv for this directory'
group 'virtualenv'
eval "deactivate"
rmvirtualenv "$(basename `pwd`)"
eval "rm .env"
}
function rmenvbranch {
about 'removes virtualenv for this directory'
group 'virtualenv'
eval "deactivate"
rmvirtualenv "$(basename `pwd`)@$SCM_BRANCH"
}

View File

@ -1,8 +1,9 @@
cite about-plugin
about-plugin 'load pyenv, if you are using it'
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
export PYENV_PATH=`which pyenv`
export PATH="$PYENV_PATH:$PATH"
[[ `which pyenv` ]] && eval "$(pyenv init -)"
#Load pyenv virtualenv if the virtualenv plugin is installed.

View File

@ -14,7 +14,7 @@ RVM_THEME_PROMPT_SUFFIX="|"
function prompt_command() {
#PS1="${bold_cyan}$(scm_char)${green}$(scm_prompt_info)${purple}$(ruby_version_prompt) ${yellow}\h ${reset_color}in ${green}\w ${reset_color}\n${green}→${reset_color} "
PS1="\n${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} "
PS1="\n${yellow}$(virtualenv_prompt)$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} "
}
PROMPT_COMMAND=prompt_command;