Created
August 3, 2016 16:23
-
-
Save bhenderson/611114de4a4a60f68534b200f2f6fdeb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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