Hot answers tagged


It depends on the shell you are running in. If it is a POSIX confirming shell e.g. bash, ash,ash, sh, and some others e.g. csh, tcsh then echo $0 will return the shell's name e.g. ~ $ bash bash-3.2$ echo $0 bash or ~ $ ksh $ echo $0 ksh However not all shells are POSIX e.g. I used to use ipython shell profile and now fish


Under csh family shells, you'll got your running shell with this command: % echo $shell If csh was run, directly or undirectly, from a Bourne family shell that had its SHELL variable exported, the latter being the common case, the SHELL variable would stay untouched so echo $SHELL will still show the its previous value which would be confusing. This is ...


Another way would be to check which TTY your terminal is attached to and check which shell is running on that tty. Then you could look at the PID (Process ID) and PPID (Parent Process ID) in case your shell has spawned another shell as a child process: MacBook:~$ w 15:16 up 8 days, 16:11, 2 users, load averages: 1.26 1.22 1.24 USER TTY FROM ...

Only top voted, non community-wiki answers of a minimum length are eligible