Skip to content

Instantly share code, notes, and snippets.

@kapb14
Created October 15, 2018 14:04
Show Gist options
  • Select an option

  • Save kapb14/35495251fde3ea817fe5ba71fe28c9d6 to your computer and use it in GitHub Desktop.

Select an option

Save kapb14/35495251fde3ea817fe5ba71fe28c9d6 to your computer and use it in GitHub Desktop.
pyenv configuration for fish shell

pyenv for fish shell

pyenv on GitHub

issue about fish shell support

PYENV_ROOT is set to /opt/pyenv

  1. git clone https://github.com/pyenv/pyenv.git /opt/pyenv
  2. put settings below in correspond ~/.config/fish/ configs:
  • config.fish => ~/.config/fish/config.fish
  • conf.d-pyenv.fish => ~/.config/fish/conf.d/pyenv.fish
  • completions-pyenv.fish => ~/.config/fish/completions/pyenv.fish
  1. restart fish session
function __fish_pyenv_needs_command
set cmd (commandline -opc)
if [ (count $cmd) -eq 1 -a $cmd[1] = 'pyenv' ]
return 0
end
return 1
end
function __fish_pyenv_using_command
set cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]
return 0
end
end
return 1
end
complete -f -c pyenv -n '__fish_pyenv_needs_command' -a '(pyenv commands)'
for cmd in (pyenv commands)
complete -f -c pyenv -n "__fish_pyenv_using_command $cmd" -a \
"(pyenv completions (commandline -opc)[2..-1])"
end
if test -z "$PYENV_ROOT"
set pyenv_root /opt/pyenv
set -x PYENV_ROOT "$pyenv_root"
else
set pyenv_root "$PYENV_ROOT"
end
set -x PATH $PYENV_ROOT/bin $PATH
if not command -s pyenv > /dev/null
echo "Install <github.com/yyuu/pyenv> to use 'pyenv'."
exit 1
end
set -l pyenv_root ""
if status --is-login
set -x PATH "$pyenv_root/shims" $PATH
set -x PYENV_SHELL fish
end
command mkdir -p "$pyenv_root/"{shims,versions}
# add to your ~/.config/fish/config.fish
status --is-interactive; and . (pyenv init - | psub)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment