In OS X, you can add a shell to /etc/shells and set it as a user's default shell, such that when they open the terminal they are presented with that shell. In addition, you have the option to open all new terminal tabs in the same dir as the currently focused tab, this is achieved by sending the pwd to the terminal app via a function embedded in the prompt, and the new tab passing that info to login or bash. My question is how is this info passed to login or bash, as arguments? Env variable?

The reason I want to know is that the shells that ship with OS X don't show the cd /path/to/last/dir that is the first command run when you open a tab (with the dir settings as desired) while using a shell that doesn't ship with OS X (eg a modern bash), and I'd like to find a way to replicate that in my setup.

The terminal has one /usr/local/bin/bash --noediting -i running and each tab has the following running:

login -pf camdennarzt -bash

and if you are using a shell that doesn't ship with OS X then the first command run is cd /path/to/last/dir but it runs at a prompt like the command was typed in. And if you are using an included shell, the dir is still changed but the command that does it isn't shown.

/etc/bashrc_Apple_Terminal seems to be related.

In Sierra it shows that the shell is started as: login -pfl camdennarzt /bin/bash -c 'exec -la bash /usr/local/bin/bash' and the problem is gone, so that may be related.

Your Answer

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

Browse other questions tagged or ask your own question.