Skip to content

Instantly share code, notes, and snippets.

@bhenderson
Created August 3, 2016 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhenderson/611114de4a4a60f68534b200f2f6fdeb to your computer and use it in GitHub Desktop.
Save bhenderson/611114de4a4a60f68534b200f2f6fdeb to your computer and use it in GitHub Desktop.
# MultiRuby Switcher: see multiruby for installs
mrs() {
local path="$HOME/.multiruby/install/$1/bin:"
if test "$1" = "system" -o "$1" = ""; then
echo >&2 "using system"
path=
elif ! test -d "${path%:}"; then
echo >&2 "$1 not available"
return 1
fi
export PATH="${path}$(printenv PATH | tr : '\n' | grep -v -e '/.gem/' -e '/.multiruby/' | tr '\n' :)"
export PATH="$(gem env path | tr : '\n' | head -n1):${PATH%:}"
}
_mrs() {
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [ $prev = "mrs" ]; then
COMPREPLY=( $( cd $HOME/.multiruby/install; compgen -d -- $cur ) )
fi
}
complete -F _mrs mrs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment