From e8ad78f8379766dcd0a94ca5e6dd703f82e5a714 Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Wed, 3 Oct 2012 12:19:42 +0900 Subject: [PATCH] add `pyenv push` and `pyenv pop` to manage version stack --- README.md | 28 ++++++++++++++++++++++++++++ libexec/pyenv-sh-pop | 18 ++++++++++++++++++ libexec/pyenv-sh-push | 14 ++++++++++++++ 3 files changed, 60 insertions(+) create mode 100755 libexec/pyenv-sh-pop create mode 100755 libexec/pyenv-sh-push diff --git a/README.md b/README.md index 86fce0b0..e253b47a 100644 --- a/README.md +++ b/README.md @@ -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 + ### 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 + ### 3.3 pyenv shell Sets a shell-specific Python version by setting the `PYENV_VERSION` diff --git a/libexec/pyenv-sh-pop b/libexec/pyenv-sh-pop new file mode 100755 index 00000000..944422d3 --- /dev/null +++ b/libexec/pyenv-sh-pop @@ -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