Skip to content

Instantly share code, notes, and snippets.

@fnichol
Created August 14, 2010 18:02
Show Gist options
  • Save fnichol/524537 to your computer and use it in GitHub Desktop.
Save fnichol/524537 to your computer and use it in GitHub Desktop.
Some RVM install time sugar
#!/usr/bin/env bash
# ## Installing RVM as a User
#
# bash < <( curl -s https://rvm.beginrescueend.com/install/rvm )
# bash < <( curl -L http://bit.ly/rvm_sugar )
# [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
#
# ## Installing RVM System Wide (become the root user)
#
# bash < <( curl -s https://rvm.beginrescueend.com/install/rvm )
# bash < <( curl -L http://bit.ly/rvm_sugar )
# [[ -s "/usr/local/rvm/scripts/rvm" ]] && . /usr/local/rvm/scripts/rvm
#
# ## Installing Rubies: An Example
#
# rvm 1.9.2,1.8.7,jruby,rbx,ree install && rvm 1.9.2 --default
#
global_gems=( "bundler -v1.1.pre.5" awesome_print wirble interactive_editor powder )
default_gems=( chef vagrant homesick github gollum creole rdiscount )
echo "== loading in rvm environment"
if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]]; then
source "/usr/local/rvm/scripts/rvm"
fi
rvmrc="$HOME/.rvmrc"
rvm_create_gemsets="rvm_gemset_create_on_use_flag"
if [[ ! -f "$rvmrc" ]] || ! grep -q "^${rvm_create_gemsets}=" "$rvmrc"; then
echo "== ${rvmrc}: create gemsets automatically as needed"
echo "${rvm_create_gemsets}=1" >> "$rvmrc"
fi
gemrc="$HOME/.gemrc"
if [[ ! -f "$gemrc" ]]; then
echo "== ${gemrc}: skip ri/rdoc when installing gems"
cat > "$gemrc" <<END_OF_GEMRC
---
gem: --no-ri --no-rdoc
END_OF_GEMRC
fi
aprc="$HOME/.aprc"
if [[ ! -f "$aprc" ]]; then
echo "== ${aprc}: modify awesome_print colors to work with black background"
cat > "$aprc" <<END_OF_APRC
AwesomePrint.defaults = {
:indent => 2,
:color => {
:bigdecimal => :cyan,
:fixnum => :cyan,
:float => :cyan
}
}
END_OF_APRC
fi
irbrc="$HOME/.irbrc"
if [[ ! -f "$irbrc" ]]; then
echo "== ${irbrc}: add history/load in awesome_print (irbrc start point)"
cat > "$irbrc" <<END_OF_IRBRC
require "rubygems"
require "irb/ext/save-history"
require "ap"
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
IRB::Irb.class_eval do
def output_value
ap @context.last_value
end
end
END_OF_IRBRC
fi
global_dot_gems="${rvm_path}/gemsets/global.gems"
echo "== ${global_dot_gems}: adding global gems for new rubies..."
for gem in "${global_gems[@]}"; do
if ! grep -q "^$gem" "$global_dot_gems"; then
echo ">>>> adding \"${gem}\""
echo "$gem" >> "$global_dot_gems"
fi
done; unset gem
echo "== ${global_dot_gems}: closed."
default_dot_gems="${rvm_path}/gemsets/default.gems"
echo "== ${default_dot_gems}: adding default gems for new rubies..."
for gem in "${default_gems[@]}"; do
if ! grep -q "^$gem" "$default_dot_gems"; then
echo ">>>> adding \"${gem}\""
echo "$gem" >> "$default_dot_gems"
fi
done; unset gem
echo "== ${default_dot_gems}: closed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment