Easily switch pyenv virtualenvs with peco

[Addition] I have released a generalized version of this that can be used in rbenv etc., so I think you should use this.

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

Convenient

Recommended Posts

Easily switch pyenv virtualenvs with peco
Easily daemonized with Supervisor
Easily beep with python
Check when the version does not switch with pyenv
Install python with pyenv
Build python3.x with pyenv
Easily serverless with Python with chalice
Easily write if-elif with lambda
Reinstall python with pyenv with -fPIC
Easily build CNN with Keras
Switch python to 2.7 with alternatives
python with pyenv and venv
Switch virtual environment with jupyter
Easily cProfile with a decorator