diff --git a/README.md b/README.md index b821d602..13892509 100644 --- a/README.md +++ b/README.md @@ -216,12 +216,20 @@ easy to fork and contribute any changes back upstream. ~~~ - For **Fish shell**: + + Execute this interactively: ~~~ fish set -Ux PYENV_ROOT $HOME/.pyenv - set -Ux fish_user_paths $PYENV_ROOT/bin $fish_user_paths - pyenv init --path | source + set -U fish_user_paths $PYENV_ROOT/bin $fish_user_paths ~~~ + And add this to `~/.config/fish/config.fish`: + ~~~ fish + status is-login; and pyenv init --path | source + ~~~ + + If fish is not your login shell, also follow the bash/zsh instructions to add to ~/.profile. + - **Proxy note**: If you use a proxy, export `http_proxy` and `https_proxy` too. 3. **Add `pyenv init` to your shell** to enable shims and autocompletion. @@ -239,8 +247,9 @@ easy to fork and contribute any changes back upstream. ~~~ - For **Fish shell**: + Add this to `~/.config/fish/config.fish`: ~~~ fish - echo -e '\n\n# pyenv init\nif command -v pyenv 1>/dev/null 2>&1\n pyenv init - | source\nend' >> ~/.config/fish/config.fish + pyenv init - | source ~~~ **General warning**: There are some systems where the `BASH_ENV` variable is configured diff --git a/libexec/pyenv-init b/libexec/pyenv-init index f8f46a72..f43de040 100755 --- a/libexec/pyenv-init +++ b/libexec/pyenv-init @@ -83,58 +83,59 @@ function help_() { ksh ) profile='~/.profile' ;; - fish ) - profile='~/.config/fish/config.fish' - ;; * ) profile='your profile' ;; esac - { echo "# Add pyenv executable to PATH by adding" - echo "# the following to ~/.profile:" - echo + { case "$shell" in fish ) + echo "# Add pyenv executable to PATH by running" + echo "# the following interactively:" + echo echo 'set -Ux PYENV_ROOT $HOME/.pyenv' - echo 'set -Ux fish_user_paths $PYENV_ROOT/bin $fish_user_paths' - ;; - * ) + echo 'set -U fish_user_paths $PYENV_ROOT/bin $fish_user_paths' + echo + echo "# Load pyenv automatically by appending" + echo "# the following to ~/.config/fish/config.fish:" + echo + echo 'status is-login; and pyenv init --path | source' + echo 'pyenv init - | source' + echo + echo "# If fish is not your login shell," + echo "# add the following to ~/.profile:" + echo echo 'export PYENV_ROOT="$HOME/.pyenv"' echo 'export PATH="$PYENV_ROOT/bin:$PATH"' - ;; - esac - echo - echo "# Load pyenv automatically by appending" - echo "# the following to ${profile}:" - echo - case "$shell" in - fish ) - echo 'pyenv init - | source' - ;; - * ) - echo 'eval "$(pyenv init -)"' - ;; - esac - echo - echo "# and the following to ~/.profile:" - echo - case "$shell" in - fish ) - echo 'pyenv init --path | source' - ;; - * ) echo 'eval "$(pyenv init --path)"' + echo + ;; + * ) + echo "# Add pyenv executable to PATH by adding" + echo "# the following to ~/.profile:" + echo + echo 'export PYENV_ROOT="$HOME/.pyenv"' + echo 'export PATH="$PYENV_ROOT/bin:$PATH"' + echo + echo "# Load pyenv automatically by appending" + echo "# the following to ${profile}:" + echo + echo 'eval "$(pyenv init -)"' + echo + echo "# and the following to ~/.profile:" + echo + echo 'eval "$(pyenv init --path)"' + echo + echo '# If your ~/.profile sources '"${profile}"',' + echo '# the lines should be inserted before the part' + echo '# that does that.' + echo + echo '# Make sure to restart your entire logon session' + echo '# for changes to ~/.profile to take effect.' + echo ;; esac - echo - echo '# If your ~/.profile sources '"${profile}"',' - echo '# the lines should be inserted before the part' - echo '# that does that.' - echo - echo '# Make sure to restart your entire logon session' - echo '# for changes to ~/.profile to take effect.' - echo } >&2 }