Skip to content

Instantly share code, notes, and snippets.

@mattbrictson
Last active October 26, 2015 07:28
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattbrictson/1514511 to your computer and use it in GitHub Desktop.
Save mattbrictson/1514511 to your computer and use it in GitHub Desktop.
"r" shortcut in bash for "rails" and "rake"
# Shortcut for `bundle exec rails` and `bundle exec rake`.
# If bin/rails and bin/rake are available, use them instead as they are much
# faster to execute than `bundle exec`.
function r() {
if [[ "g|generate|c|console|s|server|db|dbconsole|r|runner|new" =~ $1 ]]; then
if [ -x bin/rails ]; then
bin/rails "$@"
elif [ -x script/rails ]; then
script/rails "$@"
else
rails "$@"
fi
else
if [ -x bin/rake ]; then
bin/rake "$@"
elif [ -x script/rake ]; then
script/rake "$@"
else
rake "$@"
fi
fi
}
#!/usr/bin/env ruby
# script/rake
# Run rake after loading Rails/Bundler; faster than `bundle exec rake`
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rake'
Rake.application.run
@mattbrictson
Copy link
Author

Read the blog post associated with this Gist: Invoke rails and rake faster! And with fewer mistakes.

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