-
-
Save fcoury/161006 to your computer and use it in GitHub Desktop.
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
| # These aliases provide a single shell command: r | |
| # | |
| # r opens up three tabs in Terminal with: | |
| # | |
| # * script/console | |
| # * tail -f log/development.log | |
| # * Also starts $EDITOR | |
| # * You could make it load script/server, but I use this: | |
| # http://www.fngtps.com/passenger-preference-pane | |
| # | |
| # Usage (after sourcing this file from .bashrc): | |
| # | |
| # r project_path | |
| # | |
| # Notice that r() uses cv -- this can be replaced | |
| # with cd or aliases to your rails project paths | |
| # | |
| # cv is from CDargs: | |
| # http://www.skamphausen.de/cgi-bin/ska/CDargs | |
| # | |
| # I reuse cdargs aliases so I can type r d[tab] | |
| # This autocompletes my project names: | |
| # | |
| # if [ -e "$DOTFILES/lib/cdargs-bash.sh" ]; then | |
| # . "$DOTFILES/lib/cdargs-bash.sh" | |
| # # Use the completion from cdargs for my "r" alias | |
| # complete $nospace -S / -X '*/' -F _cdargs_aliases r | |
| # fi | |
| alias ss='./script/server' # script/server | |
| alias sc='./script/console' # script/console | |
| # Opens a new tab with the cwd | |
| function tab { | |
| osascript -e " | |
| tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down | |
| tell application \"Terminal\" to do script \"cd $PWD\" in selected tab of the front window | |
| " > /dev/null 2>&1 | |
| } | |
| function as_terminal_cmd { | |
| osascript -e "tell application \"Terminal\" to do script \"$1\" in selected tab of the front window" | |
| } | |
| function terminal_title { | |
| if [[ $# -eq 1 && -n "$@" ]]; | |
| then | |
| printf "\e]0;${@}\a"; | |
| fi | |
| } | |
| # cd into a rails dir, start mvim and rails console | |
| function r { | |
| cv $1 | |
| as_terminal_cmd "terminal_title Log" | |
| as_terminal_cmd "tail -f log/development.log" | |
| tab | |
| as_terminal_cmd "terminal_title Console" | |
| as_terminal_cmd "sc" | |
| tab | |
| $EDITOR & | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment