We can run something like chsh -s /usr/local/bin/zsh
to set a new default shell. Is there a command we can run to know what that shell is?
I don’t mean
For macOS:
dscl . -read /Users/username UserShell
For the current macOS user:
dscl . -read ~/ UserShell
To parse the path inline using sed
:
dscl . -read ~/ UserShell | sed 's/UserShell: //'
Using $SHELL
will report the current login shell, not the default login shell. In certain cases, these are not the same. For example, when working in an IDE such as Visual Studio Code which opens an integrated terminal without consulting the default shell.
In addition, as pointed out by Martin C. Martin, $SHELL
is a constant that will not change after chsh
changes the default login shell.