22

When I use Command + t to open an new tab in terminal, it always open my home directory.

How can I new a tab which open the same directory?

0

5 Answers 5

10

As of Mac OS X Lion 10.7, Terminal will do this by default if you're using bash as your shell (which is the default).

You can set preferences to decide whether to have new tabs and/or windows open at the same directory as the current terminal:

Terminal > Preferences > Startup > New windows/tabs open with > Same Working Directory

This works by having your shell (or other programs) send an escape sequence to tell Terminal the current working directory. The code to do this is in the system-wide bash configuration file /etc/bashrc.

If you're using zsh, I've adapted and expanded the code for /etc/zshrc in my answer to Resume Zsh-Terminal (OS X Lion).

23

command + t

(for tab)

Typing in more to satisfy Stackoverflow's requirement that Body is at least 30 characters.

1
  • ... and "command + w" to close the tab.
    – Hem
    Feb 2, 2022 at 18:04
1

Follow the steps as shown here : Open a new tab on Terminal with the same path

0
1

I would suggest you to use iTerm 2 and learn more about customizing it to your needs

enter image description here

4
  • It doesn't look like iTerm has a future, the most recent 0.x version will be two years old in september. iterm2.com perhaps?
    – Daniel Beck
    May 20, 2011 at 10:39
  • true, the screenshot is for iTerm2 :)
    – balexandre
    May 20, 2011 at 13:28
  • 1
    @DanielBeck Funny seeing as iterm is still around now and gaining in popularity
    – Mosselman
    Sep 6, 2018 at 9:44
  • 1
    @Mosselman Do you have a reference? It doesn't seem anything has changed: "iTerm project is currently on hold (See the goodbye note from Fabian). We recommend you to check out iTerm 2, a new project that is based on iTerm and has many new features and enhancements." per iterm.sourceforge.net Also "iTerm2 is a more up to date fork as the original project is not maintained." from launchpad.net/iterm
    – Daniel Beck
    Sep 7, 2018 at 9:41
1

On MAC 10

Terminal > Preferences > General>

change follow attributes to

New windows open with > Same Working Directory
New tabs open with > Same Working Directory

To apply change press command + T

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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