Skip to content

Instantly share code, notes, and snippets.

@tissak
Created February 24, 2011 03:10
Show Gist options
  • Save tissak/841687 to your computer and use it in GitHub Desktop.
Save tissak/841687 to your computer and use it in GitHub Desktop.
Sutto's global rails 2 & 3 starter scripts
rails_version() {
which -s rails && rails -v 2>/dev/null | sed 's/Rails //'
}
r() {
local name="$1"
shift
if [[ -z "$name" ]]; then
echo "Usage: $0 command *args" >&2
return 1
fi
if [[ -x "./script/$name" ]]; then
./script/$name $@
elif [[ -x "./script/rails" ]]; then
./script/rails "$name" $@
elif [[ -n "$(rails_version | grep '^3')" ]]; then
rails "$name" $@
else
echo "Please change to the root of your project first." >&2
return 1
fi
}
alias ss="r server"
alias sc="r console"
alias sp='r plugin'
alias sg='r generate'
alias sd="r dbconsole"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment