"Exotic" shells on MacOS

Problem defined

If you try to change your default shell from ZSH to Bash (even Bash 5 over it's native Bash 3), the Apple system responds with some nags, but overall is happy with you. If you try to feed it something like Fish, it will yell at you for even thinking of changing to a "non-standard" shell.

We can assume Apple and others are doing this to preserve the integrity of their internal subsystems, which are likely still glued together by many shell scripts. If the default interpreter changes to something that isn't POSIX compliant, there is a decent chance something may break in all of those little glue points.

Besides Apple, it's a good idea to stick to this philosophy, at least for a few years. The dust has already settled over the SysV init, which has been completely superseded by SystemD. But the traditional POSIX shell is still seen as an integral part of the Unix system.

A solution

iTerm2 and any terminal emulator worth it's salt will allow you to change the default login shell. This lets the user use the Fish shell for example, without needing to chsh anything or any other hack.

That's it. Keep reading if you want to see a more general solution, which may be useful if you are using multiple terminal emulators.

.bash_profile hack

A hack can used (a [ -t 1 ] gate), to ensure the Fish shell starts up whenever the user wants to allocate a new TTY. This includes normal use such as when the login shell is set to either ZSH or Bash, shells which are not "exotic." Luckily, there is a workaround for those of us who use multiple terminal emulators and don't want to configure each and every one.

The full hack looks like: if [ -t 1 ]; then exec fish; fi. This can be roughly transliterated as, "If I'm a tty, then replace me with Fish."This will drop the user into the fish shell and exec ensures the parent shell is removed.

This ensures compatibility with existing shell scripts in the Apple system, while allowing the user to use a better shell.

Thoughts on ZSH

ZSH might be an ok shell, but it's semantics hardly depart from Bash. Thus I did not use the ZSH interface. OhMyZSH or OhMyAnything seems like a little too much cruft that you wouldn't want in an environment fit for daily use.