Permalink
Browse files

add `pyenv push` and `pyenv pop` to manage version stack

  • Loading branch information...
Yamashita Yuu
Yamashita Yuu committed Oct 3, 2012
1 parent aede700 commit e8ad78f8379766dcd0a94ca5e6dd703f82e5a714
Showing with 60 additions and 0 deletions.
  1. +28 −0 README.md
  2. +18 −0 libexec/pyenv-sh-pop
  3. +14 −0 libexec/pyenv-sh-push
View
@@ -199,6 +199,20 @@ within these Python versions are searched by specified order.
$ pyenv which python
/home/yyuu/.pyenv/versions/2.7.3/bin/python
+You can manage your version stack by `pyenv push` and `pyenv pop`.
+
+ $ pyenv global
+ 2.7.3
+ 3.2.3
+ $ pyenv push 3.3.0
+ $ pyenv global
+ 2.7.3
+ 3.2.3
+ 3.3.0
+ $ pyenv pop
+ 2.7.3
+ 3.2.3
+
### <a name="section_3.2"></a> 3.2 pyenv local
Sets a local per-project Python version by writing the version name to
@@ -228,6 +242,20 @@ within these Python versions are searched by specified order.
$ pyenv which python
/home/yyuu/.pyenv/versions/2.7.3/bin/python
+You can manage your version stack by `pyenv push` and `pyenv pop`.
+
+ $ pyenv local
+ 2.7.3
+ 3.2.3
+ $ pyenv push 3.3.0
+ $ pyenv local
+ 2.7.3
+ 3.2.3
+ 3.3.0
+ $ pyenv pop
+ 2.7.3
+ 3.2.3
+
### <a name="section_3.3"></a> 3.3 pyenv shell
Sets a shell-specific Python version by setting the `PYENV_VERSION`
View
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+set -e
+[ -n "$PYENV_DEBUG" ] && set -x
+
+IFS=: versions=($(pyenv-version-name))
+
+length="${#versions[@]}"
+PYENV_VERSION_NAMES=()
+for ((i=0; i<length-1; i++)); do
+ PYENV_VERSION_NAMES=("${PYENV_VERSION_NAMES[@]}" "${versions[$i]}")
+done
+
+if [ -n "$PYENV_VERSION" ]; then
+ IFS=: PYENV_VERSION="${PYENV_VERSION_NAMES[*]}"
+ echo "export PYENV_VERSION=\"${PYENV_VERSION}\""
+else
+ pyenv-version-file-write "$(pyenv-version-file)" "${PYENV_VERSION_NAMES[@]}"
+fi
View
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+set -e
+[ -n "$PYENV_DEBUG" ] && set -x
+
+IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name))
+versions=("$@")
+PYENV_VERSION_NAMES=("${PYENV_VERSION_NAMES[@]}" "${versions[@]}")
+
+if [ -n "$PYENV_VERSION" ]; then
+ IFS=: PYENV_VERSION="${PYENV_VERSION_NAMES[*]}"
+ echo "export PYENV_VERSION=\"${PYENV_VERSION}\""
+else
+ pyenv-version-file-write "$(pyenv-version-file)" "${PYENV_VERSION_NAMES[@]}"
+fi

0 comments on commit e8ad78f

Please sign in to comment.