How to check shell version on Mac

Mac has bash and zsh the profile for bash and zsh is different, sometimes we want to change path on profile files, but in order to find…

How to check shell version on Mac

Mac has bash and zsh the profile for bash and zsh is different, sometimes we want to change path on profile files, but in order to find which file to change, we need to identify which shell we are using, this article list the method to identify which shell are used in the terminal.

Check shell versionecho $0
echo $SHELL
$SHELL --version

Examples

Bash$ echo $0
-bash$ echo $SHELL
/bin/bash$ $SHELL --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin21)
Copyright (C) 2007 Free Software Foundation, Inc.

zsh% echo $0
-zsh% echo $SHELL
/bin/zsh% $SHELL --version
zsh 5.8.1 (x86_64-apple-darwin21.0)

Change default shell on Mac

We can use chsh to change default shell on Mac like below:# Change to bash
chsh -s /bin/bash# Change to zsh
chsh -s /bin/zsh