8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pecoでpyenvのvirtualenvsを簡単に切り替える

Last updated at Posted at 2015-05-30

【追記】これを汎化してrbenvなどでも使えるようにした物を公開しましたので、こちらを使うと良いと思います。

giginet/peco-anyenv


.zshrc
function venv() {
    venvs=`pyenv versions | peco`
    venv0=`echo $venvs | cut -d' ' -f1`
    venv1=`echo $venvs | cut -d' ' -f2`
    if [[ $venv0 == "*" ]]; then
      venv_name=$venv1
    else
      venv_name=`echo $venvs| awk '{ print $1 }'`
    fi

    mode=local
    if [[ $1 == "--global" ]]; then
      mode=global
    fi
    echo "Set ${mode} Python version to ${venv_name}"
    pyenv $mode $venv_name
}
$ venv # pyenv local
$ venv --global #pyenv global

便利

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?