OS X El Capitan 10.11 Terminal 2.6 won’t open new tabs with same working directory

osx-el-capitanterminal.appzsh

I am using the default settings for Terminal, but when I create a new tab my working directory is always set to my home folder instead of the current working directory of the previous tab.

Here's an image of my Terminal Preferences:

http://i.stack.imgur.com/TIIzN.png

As you can see in the General settings, "New tabs open with:” is set to “Same Working Directory". That does not seem to be working. I think I remember this working in older versions of Terminal.

My default login shell is set to /bin/zsh, and I have no ~/.zshrc.

I would like to be able to solve this issue without installing something like oh-my-zsh or having to add something to ~/.zshrc. This should work without any of that. (At least it does in iTerm2.)

Best Answer

By default on OS X, Bash is configured to communicate the current working directory to Terminal using escape sequences at each prompt, using the PROMPT_COMMAND environment variable.

Prior to OS X El Capitan 10.11, this code is found in /etc/bashrc. In 10.11 and later, it has been moved to the Terminal-specific /etc/bashrc_Apple_Terminal file and /etc/bashrc executes the appropriate terminal-specific file.

Current versions of Oh My Zsh! have similar code to communicate the working directory to Terminal.

The most likely reason this stopped working is that you changed your configuration. Perhaps you were using Bash before or you had Oh My Zsh installed and now you don't. Another possibility is that you used to have your shell configured to set the terminal window or tab (aka “icon”) title to contain the working directory pathname: as a convenience for older configurations, if the working directory isn't explicitly set but the window or tab title contains a valid local pathname, Terminal will treat it as the current working directory.

Related Question