How to check what shell I am using in a terminal? What is the shell I am using in MacOS?
|
Several ways, from most to least reliable (and most-to-least "heavy"):
|
|||||||||||||||||||||
|
|
I've found that the following works in the four shells I have installed on my system (bash, dash, zsh, csh):
The following works on zsh, bash, and dash, but not on csh:
|
|||||||||
|
|
As the question asks for the shell used and does not talk about the potential arguments passed to it, here is a way that avoid showing them:
|
|||
|
|
|
A note about some lighter implementations (Android phones, busybox, etc.): |
|||||
|
|
A mix of all the other answers, compatible with Mac (comm), Solaris (fname) and Linux (cmd):
|
|||||
|
|
The pid of the running shell is given by the var $$ (in most shells).
Using backticks to make jsh (Heirlomm shell) work. In many shells the direct test of The check that The last Tests on more systems will help, please make a comment if it doesn't work for you. Does not work in |
|||||||||||||
|
|
There are two really simple ways:
The usage of |
||||
|
|
|
I set
The |
||||
|
|
|
You can simply use |
|||||
|
|
|||||
|
|
This works too:
|
|||||
|
echo #SHELLis not quite it. See # 3 in the Answer by geekosaur. – Basil Bourque Feb 4 '17 at 23:18xterm -e /bin/catbut I am not happy calling/bin/cata shell. – Basile Starynkevitch Aug 24 '17 at 10:26