Deactivate pyenv in current shell

前端 未结 7 2089
日久生厌
日久生厌 2021-02-13 02:22

My .bashrc has this:

enable-pyenv () {
    # Load pyenv automatically by adding
    # the following to your profile:

    export PATH=\"$HOME/.pyenv/bin:$PATH\"
         


        
7条回答
  •  伪装坚强ぢ
    2021-02-13 03:10

    This bash function removes pyenv paths and unsets environment variables. (I have just extended shivams sed command, which may not work on BSD systems.)

    function deactivate-pyenv {
    
        # check that virtual environment is not currently active
        if [ ! -z ${PYENV_VIRTUAL_ENV+x} ]; then
            echo ""
            echo "Cannot proceed while virtual environment is active"
            echo ""
            return 1
        fi
    
         # remove pyenv paths
         export PATH=`echo $PATH | tr ':' '\n' | sed '/pyenv/d' | tr '\n' ':' | sed -r 's/:$/\n/'`        
    
        # unset pyenv environment variables
        unset "${!PYENV@}"
    
    }
    

提交回复
热议问题