Created
May 16, 2015 17:31
-
-
Save Thorsson/a1207c08541b07cc8f45 to your computer and use it in GitHub Desktop.
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
function work { | |
if [ -z "$1" ]; then | |
cd ~/Projects/ && ls | |
else | |
project=~/Projects/$1 | |
if [ -d $project ]; then | |
cd $project; | |
osascript 2>/dev/null <<EOF | |
tell application "Terminal" | |
activate | |
do script with command "cd \"$PWD\"; guard" in window 1 | |
end tell | |
tell application "System Events" | |
tell process "Terminal" to keystroke "t" using command down | |
end | |
tell application "Terminal" | |
activate | |
do script with command "cd \"$PWD\"; rails s" in window 1 | |
end tell | |
tell application "System Events" | |
tell process "Terminal" to keystroke "t" using command down | |
end | |
tell application "Terminal" | |
activate | |
do script with command "cd \"$PWD\"; rails c" in window 1 | |
end tell | |
tell application "System Events" | |
tell process "Terminal" to keystroke "t" using command down | |
end | |
tell application "Terminal" | |
activate | |
do script with command "cd \"$PWD\"; subl ." in window 1 | |
end tell | |
EOF | |
else | |
printf "\033[0;31mThere is no project, listing matches\033[0m\n" | |
cd ~/Projects/ && ls | grep $1 | |
printf "\033[0;31mThere is no project, listing matches\033[0m\n" | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Paste this into .bash_aliases file or somewhere that is loaded. User it with:
work project_name
And it will open four tabs, one for guard, one for rails server, one for rails console and one free tab to run commands. The last tab will also open the project in sublime editor.