diff options
author | Atem18 <messer.kevin@gmail.com> | 2013-12-01 23:45:55 +0100 |
---|---|---|
committer | Atem18 <messer.kevin@gmail.com> | 2013-12-01 23:45:55 +0100 |
commit | 06bd72f842480d9556a1cc28cc340f1be7e7c79b (patch) | |
tree | baeb90abad8afab94f0535fe8f949b1d8df591be /plugins/pyenv | |
parent | 84e178fa3d5e6e5bc36cb353c5c051d4f12ec35d (diff) | |
parent | 5643fac8870c2df284f1ccceab35fb1fe343fa3f (diff) | |
download | zsh-06bd72f842480d9556a1cc28cc340f1be7e7c79b.tar.gz zsh-06bd72f842480d9556a1cc28cc340f1be7e7c79b.tar.bz2 zsh-06bd72f842480d9556a1cc28cc340f1be7e7c79b.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'plugins/pyenv')
-rw-r--r-- | plugins/pyenv/pyenv.plugin.zsh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh new file mode 100644 index 000000000..b3dc7aa17 --- /dev/null +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -0,0 +1,31 @@ +_homebrew-installed() { + type brew &> /dev/null +} + +_pyenv-from-homebrew-installed() { + brew --prefix pyenv &> /dev/null +} + +FOUND_PYENV=0 +pyenvdirs=("$HOME/.pyenv" "/usr/local/pyenv" "/opt/pyenv") +if _homebrew-installed && _pyenv-from-homebrew-installed ; then + pyenvdirs=($(brew --prefix pyenv) "${pyenvdirs[@]}") +fi + +for pyenvdir in "${pyenvdirs[@]}" ; do + if [ -d $pyenvdir/bin -a $FOUND_PYENV -eq 0 ] ; then + FOUND_PYENV=1 + export PYENV_ROOT=$pyenvdir + export PATH=${pyenvdir}/bin:$PATH + eval "$(pyenv init --no-rehash - zsh)" + + function pyenv_prompt_info() { + echo "$(pyenv version-name)" + } + fi +done +unset pyenvdir + +if [ $FOUND_PYENV -eq 0 ] ; then + function pyenv_prompt_info() { echo "system: $(python -V 2>&1 | cut -f 2 -d ' ')" } +fi |