Skip to content

Instantly share code, notes, and snippets.

@xiy
Created December 19, 2013 10:35
Show Gist options
  • Save xiy/8037314 to your computer and use it in GitHub Desktop.
Save xiy/8037314 to your computer and use it in GitHub Desktop.
rbenv functions for the fish shell, by Łukasz Niemier: https://coderwall.com/p/6hja1w
function rbenv_shell
set -l vers $argv[1]
switch "$vers"
case '--complete'
echo '--unset'
echo 'system'
command rbenv versions --bare
return
case '--unset'
set -e RBENV_VERSION
return 1
case ''
if [ -z "$RBENV_VERSION" ]
echo "rbenv: no shell-specific version configured" >&2
return 1
else
echo "$RBENV_VERSION"
return
end
case '*'
rbenv prefix "$vers" > /dev/null
set -gx RBENV_VERSION "$vers"
end
end
function rbenv_lookup
set -l vers (command rbenv versions -- bare| sort | grep -- "$argv[1]" | tail -n1)
if [ ! -z "$vers" ]
echo $vers
return
else
echo $argv
return
end
end
function rbenv
set -l command $argv[1]
[ (count $argv) -gt 1 ]; and set -l args $argv[2..-1]
switch "$command"
case shell
rbenv_shell (rbenv_lookup $args)
case local global
command rbenv $command (rbenv_lookup $args)
case '*'
command rbenv $command $args
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment