One task I keep doing each day when I work on a Rails project is:
- launch iTerm
- cd to my rails project
- start
script/server - open a new tab
- cd to my rails project
You see the ugly, terrible, horrible time wasting duplicated task (cd to my rails project). I’m so sorry I kept doing this for so long and now admit it on my blog! Now it’s there forever and in 10 years my kids will Google my name and find this stupid thing and lose all faith in their father, my wife will leave me and I’ll quit programming. I’m sorry, really…
Well, to be sure founding a family won’t make me quit programming, I made a small shell script to make this less painful and more DRYfull:
tab() # new tab from current dir
{
osascript -e "
tell application \"iTerm\"
tell the first terminal
launch session \"Default Session\"
tell the last session
write text \"cd $(pwd)\"
end tell
end tell
end tell"
}
Place this in your ~/.bash_profile then type tab in your terminal window to see some magic happen.
Let me know if this is helpful to you!









2 Comments
July 16, 2007 at 9:28 pm
Great shortcut, Marc. Thanks!
July 16, 2007 at 10:05 pm
Glad I could help Luke, I use it everyday.
BTW, I ended up doing this a lot:
tab; script/server