June 4, 2007...9:11 pm

Quick new tab from iTerm

Jump to Comments

One task I keep doing each day when I work on a Rails project is:

  1. launch iTerm
  2. cd to my rails project
  3. start script/server
  4. open a new tab
  5. 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


Leave a Reply