Skip to content

Instantly share code, notes, and snippets.

@Nyoho
Created February 23, 2013 05:12
Show Gist options
  • Save Nyoho/5018563 to your computer and use it in GitHub Desktop.
Save Nyoho/5018563 to your computer and use it in GitHub Desktop.
rbenv で新しいバージョンをインストールしてついでに gem もごっそり移行する。zsh の補完も効くようにしてみた。.zshrc の compinit に後に。
## completion for gem transition of rbenv
function gem-transition {
local tmpfile=/tmp/current_gem_list
if [ $# -ne 2 ]; then
echo "usage: command version1 version2"
return
fi
rbenv install $2
rbenv global $1
rbenv rehash
rehash
gem list | awk '{print $1}' > $tmpfile
rbenv global $2
rbenv rehash
rehash
gem i `cat $TMP_FILE`
rm $tmpfile
}
function _gem-transition {
local -a _oldversions _newversions
_oldversions=( $(rbenv completions uninstall) )
_newversions=( $(rbenv completions install) )
_arguments \
':old:($_oldversions)' \
':new:($_newversions)' && return 0
return 1;
}
compdef _gem-transition gem-transition
@eiel
Copy link

eiel commented Feb 23, 2013

ABI がどこまで同一なのかよくわからんので、いれなおしたほうがはやいと思っているクラスタ

@Nyoho
Copy link
Author

Nyoho commented Feb 23, 2013

これは入れ直しているつもりだけどそういう意味じゃない?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment