Skip to content

Instantly share code, notes, and snippets.

@Thorsson
Created May 16, 2015 17:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thorsson/a1207c08541b07cc8f45 to your computer and use it in GitHub Desktop.
Save Thorsson/a1207c08541b07cc8f45 to your computer and use it in GitHub Desktop.
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
}
@Thorsson
Copy link
Author

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.

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