Created
May 27, 2013 07:57
-
-
Save ksol/5655727 to your computer and use it in GitHub Desktop.
Ruby/rails powered shell aliases. Used with zsh, but should work with bash too.
This file contains hidden or 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
| # Classic aliases | |
| alias bx='bundle exec' | |
| alias bs='bundle show' | |
| alias bu='bundle update' | |
| alias bo='bundle open' | |
| alias bxsc='bundle exec script/console' | |
| alias bxrc='bundle exec rails console' | |
| alias bxcs='bundle exec cap staging' | |
| alias bxcp='bundle exec cap production' | |
| # Function aliases | |
| # Returns rails major version number. | |
| # Assumes gemfile.lock presence in current dir. | |
| function rails_rev() | |
| { | |
| cat Gemfile.lock | egrep '^(\ )*rails \([0-9\.]*\)' | cut -d ' ' -f 6 | cut -d '(' -f 2 | cut -d ')' -f 1 | cut -d '.' -f 1 | |
| } | |
| # Starts a rails 3 server. Extract the port from the .foremand file if existing, otherwise standard port. | |
| function bxrs() | |
| { | |
| if [ -e '.foreman' ] && [ -f '.foreman' ] && [ -r '.foreman' ]; then | |
| bundle exec rails server -p `cat .foreman | grep port | cut -c 7-` | |
| else | |
| bundle exec rails server | |
| fi | |
| } | |
| # Starts a rails 2 server. Extract the port from the .foremand file if existing, otherwise standard port. | |
| function bxss() | |
| { | |
| if [ -e '.foreman' ] && [ -f '.foreman' ] && [ -r '.foreman' ]; then | |
| bundle exec script/server -p `cat .foreman | grep port | cut -c 7-` | |
| else | |
| bundle exec script/server | |
| fi | |
| } | |
| # Starts a rails 2/3 server | |
| function bxs() | |
| { | |
| if [ $(rails_rev) -eq "3" ]; then | |
| bxrs | |
| else | |
| bxss | |
| fi | |
| } | |
| # Starts a rails 2/3 console | |
| function bxc() | |
| { | |
| if [ $(rails_rev) -eq "3" ]; then | |
| bxrc | |
| else | |
| bxsc | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment