Last active
August 29, 2015 14:01
Revisions
-
st63jun revised this gist
May 20, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -52,7 +52,7 @@ function switch_ruby() fi len=${#AVAILABLE_RUBIES[*]} if [ $1 -lt 0 -o $(expr $len - 1) -lt $1 ]; then echo "Error: Invalid number." exit 1 fi if [ -e $CURRENT ]; then -
st63jun revised this gist
May 20, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -64,7 +64,7 @@ function switch_ruby() function usage() { cat <<EOF Usage: $(basename $0) <command> Available commands: -
st63jun revised this gist
May 17, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ #!/bin/bash # # switch-ruby - Simple Ruby switcher -
st63jun created this gist
May 16, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,81 @@ #!/bin/sh # # switch-ruby - Simple Ruby switcher # # The MIT License (MIT) # # Copyright (c) 2014 Jun SAITO <jun.saito@u-cast.com> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # RUBIES_HOME=$HOME/.rubies CURRENT=$RUBIES_HOME/current AVAILABLE_RUBIES=($(find $RUBIES_HOME -maxdepth 1 -type d | grep -v "^$RUBIES_HOME$")) function show_rubies() { current=$(readlink -f $CURRENT) i=0 for ruby in ${AVAILABLE_RUBIES[@]}; do if [ $ruby == $current ]; then echo "--> " \($i\) $ruby else echo " " \($i\) $ruby fi i=$((i+1)) done } function switch_ruby() { if [ -z $1 ]; then usage exit 1 fi len=${#AVAILABLE_RUBIES[*]} if [ $1 -lt 0 -o $(expr $len - 1) -lt $1 ]; then echo "Error: Invalid index." exit 1 fi if [ -e $CURRENT ]; then unlink $CURRENT fi ln -sv ${AVAILABLE_RUBIES[$1]} $CURRENT } function usage() { cat <<EOF Usage: $0 <command> Available commands: list List installed rubies. switch <number> Switch ruby. EOF } case $1 in ls | list) show_rubies ;; sw | switch) switch_ruby $2 ;; *) usage ;; esac