Skip to content

Instantly share code, notes, and snippets.

@Sutto
Created June 2, 2010 22:46
Show Gist options
  • Save Sutto/423131 to your computer and use it in GitHub Desktop.
Save Sutto/423131 to your computer and use it in GitHub Desktop.
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