Last active
October 26, 2015 07:28
-
-
Save mattbrictson/1514511 to your computer and use it in GitHub Desktop.
"r" shortcut in bash for "rails" and "rake"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Read the blog post associated with this Gist: Invoke rails and rake faster! And with fewer mistakes.