613d116cda381b9747e22d13ed1381cec26eb8e3
- Author
- Stig Sandbeck Mathisen <ssm@fnord.no>
- Committer
- Stig Sandbeck Mathisen <ssm@fnord.no>
- Date
Diff
1diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh
2new file mode 100644
3index 0000000000000000000000000000000000000000..b3dc7aa1732966ab6ac8ef57e8b2309a317facd5
4--- /dev/null
5+++ b/plugins/pyenv/pyenv.plugin.zsh
6@@ -0,0 +1,31 @@
7+_homebrew-installed() {
8+ type brew &> /dev/null
9+}
10+
11+_pyenv-from-homebrew-installed() {
12+ brew --prefix pyenv &> /dev/null
13+}
14+
15+FOUND_PYENV=0
16+pyenvdirs=("$HOME/.pyenv" "/usr/local/pyenv" "/opt/pyenv")
17+if _homebrew-installed && _pyenv-from-homebrew-installed ; then
18+ pyenvdirs=($(brew --prefix pyenv) "${pyenvdirs[@]}")
19+fi
20+
21+for pyenvdir in "${pyenvdirs[@]}" ; do
22+ if [ -d $pyenvdir/bin -a $FOUND_PYENV -eq 0 ] ; then
23+ FOUND_PYENV=1
24+ export PYENV_ROOT=$pyenvdir
25+ export PATH=${pyenvdir}/bin:$PATH
26+ eval "$(pyenv init --no-rehash - zsh)"
27+
28+ function pyenv_prompt_info() {
29+ echo "$(pyenv version-name)"
30+ }
31+ fi
32+done
33+unset pyenvdir
34+
35+if [ $FOUND_PYENV -eq 0 ] ; then
36+ function pyenv_prompt_info() { echo "system: $(python -V 2>&1 | cut -f 2 -d ' ')" }
37+fi