In GNOME Terminal of Ubuntu when you open a new tab the new shell will automatically start you in the current working directory of the active tab shell.

E.g. if in the active tab shell I am on ~/myproject and I open a new tab, the new shell will start on ~/myproject too.

As you can guess, this is very convenient when you work deep in the directory hierarchy.

Can I configure the OSX terminal to have this behaviour?

If not, is there any free (cocoa) terminal that does this?


You may use iTerm2 and just select in preferences to "reuse previous tab's directory"

enter image description here

  • I also recommend using iTerm2 as a Terminal replacement. I did come from the linux world, and finding a good gnome-terminal replacement for mac was a must. – mspasov Mar 29 '11 at 15:37
  • 2
    I'd like to add that this behavior can be configured in recent versions of Terminal.app as well. – Gerry Aug 30 '12 at 22:22

Here's my solution from a SuperUser question

Get the current environment in your clipboard:

env | pbcopy

Open up a new Terminal window and export those environment variables

for env in `pbpaste`; do export $env; done

And to ease the process, you could always alias it, like so

alias get_env="env | pbcopy"
alias set_env="for env in `pbpaste`; do export $env; done"

So that all you have to do is

get_env +N set_env

The accepted solution:

osascript <<END 
tell app "Terminal" to do script "cd \"`pwd`\"" 

Place it in one of the folders in your path, make it executable (chmod +x filename). You can then run the name of this script to open a new terminal window in the same directory.

  • The osascript approach is nice. But it opens the shell in a new window instead of a new tab. – m000 Mar 30 '11 at 19:49

In recent OS X versions (Mavericks and Yosemite, not sure about earlier versions) in the Terminal.app preferences, "General" tab, there are options for "New windows open with" and "New tabs open with":

enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .