NullVoxPopuli NullVoxPopuli - 3 months ago 8
AppleScript Question

How do you open a terminal with a specific path already cd'ed to?

How do I use the terminal to open another terminal window but with a path I specify?

I am using automator to load my work stuff when I get to work, but I need to know how to do this:

Open Terminal and Type:

• cd Work/Company/Project/

• script/server

And then new tab in that terminal window and cd to the same folder.

Answer

This opens a new terminal window from a command prompt on Mac OSX , executes "cd /" and then keeps the window on top:

osascript -e 'tell application "terminal"' -e 'do script "cd /"' -e 'end tell'

You can put this into a script like this:

#!/bin/sh
osascript -e 'tell application "terminal"' -e "do script \"cd $1\"" -e 'end tell'

Hope this helps.