Skip to content

Instantly share code, notes, and snippets.

@jenux
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save jenux/37c86c3253a35336470a to your computer and use it in GitHub Desktop.

Select an option

Save jenux/37c86c3253a35336470a to your computer and use it in GitHub Desktop.
Set gem sources to "taobao" or reset to "rubygems.org"
#!/bin/bash
param=$1
oldsource=`gem sources | tail -n 1`
if [ "$param"x = "setx" ]; then
newsource="https://ruby.taobao.org/"
else
newsource="https://rubygems.org/"
fi
#echo "oldsource: $oldsource"
#echo "newsource: $newsource"
case "$param" in
set|reset)
gem sources --remove $oldsource
gem sources -a $newsource
echo "gem source updated:"
gem source -l
;;
*)
echo "Usage: $0 {set|reset}"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment