views:

67

answers:

3

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.

A: 

You can write a shell script to cd to that directory

So write a script that executes something like cd /user/music or something like that, save it as myscript.sh and run it using chmod +x myscript.sh.

This resource from the OS X developer network is pretty helpful

Rafe Kettler
That's doesn't answer the question at all: He wants to open a *new* terminal window at a *specified* path. Also, you don't run scripts using `chmod`.
Josh
I could write a script to have automator execute, and chmod would make the script executable =p
DerNalia
But I wouldn't know how to open a new tab in the terminal window.
DerNalia
+2  A: 

Use an applescript to do this.

e.g. Open Terminal Here

Mark
I added some details.. guess I was a bit unclear.
DerNalia
That doesn't answer his question, he wants to open a new terminal *from another terminal*.
Josh
+2  A: 

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.

Luther Blissett
this is great! any idea on the new tab thing? I want a new tab with the same folder.
DerNalia