You can check which shell you're using in terminal using the
ps command which will show you a list of currently running processes. To filter out the clutter and only show the shell name, you could use the
ps command with the following options:
ps -h -o comm -p $$
Where the flags are used for the following purposes:
-h: to remove headers;
-o comm: to print only the executable name(s). You may also use
-o comm=""to get rid of the "COMM" header;
-p $$: to narrow it down to the process id returned by "
$$" (which refers to the process id of the shell in which the command is run).
If that does not work for you, you may try using
echo $0, which (when run inside a POSIX compliant shell) would return the name of the shell.
Please note that the methods mentioned in this article are meant as a productivity tip to allow you to quickly check which shell you're using in your terminal. Please do not use these in your scripts for the purpose of getting the shell name as they may mean something else in that context.
Hope you found this post useful. It was published . Please show your love and support by sharing this post.