Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

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

enter image description here

share|improve this answer
    
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
    
Looks nice! Thanks! –  m000 Mar 30 '11 at 19:54
    
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
add comment

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:

#!/bin/sh 
osascript <<END 
tell app "Terminal" to do script "cd \"`pwd`\"" 
END

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.

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.