Today I’ve started to setup my MacBook Pro for work. It’s my first Mac and I’m not amused.

If you only know Linux, there are some pitfalls.

My .bashrc script contains the following lines:

# ~/.bashrc
# Fish
if [[ $(ps --no-header --pid=$PPID --format=cmd) != "fish" ]]
  exec fish

I use bash as my login shell, but fish as my main interactive shell. Fish is not POSIX-compliant which can lead to problems.

This will allow Bash to properly source /etc/profile and all files in /etc/profile.d. Because fish replaces the Bash process, exiting fish will also exit the terminal. Compared to the following options, this is the most universal solution, since it works both on a local machine and on a SSH server.

The command starts a shell inside bash, but drops into fish. When you use the fish shell, but want to bail out to bash, you can type bash into the prompt.

Unfortunately, the command relies on the GNU implementation of ps --no-headers. MacOs ships with the BSD variant of ps.


if [[ $(ps -p $PPID -o command | tail -n +2) != "fish" ]]
  exec fish

Now we use the -o option:

Display information associated with the space or comma sepa-
rated list of keywords specified. Multiple keywords may also
be given in the form of more than one -o option. Keywords may
be appended with an equals (`=’) sign and a string. This
causes the printed header to use the specified string instead
of the standard header. If all keywords have empty header
texts, no header line is written.