Is there an easy way by which I can tell which type of Unix shell I am in?
A command that shows whether I am in a Bash, C shell, KornShell (ksh
), tcsh, or Z shell (zsh
)?
E.g.,
whatshellisthis
Try:
echo $0
This often works across a range of shells.
Mac
ps
PID TTY TIME CMD
223 ttys000 0:00.33 -bash
OpenBSD
ps
PID TT STAT TIME COMMAND
20038 p0 Ss 0:00.01 -ksh (ksh)
22251 p0 R+ 0:00.00 ps
Or just echo $SHELL
.
The echo $SHELL
command will give you your shell name relative to root.
Every shell I know of sets the $ variable ($$) to its pid. So...
ps | grep $$
If you are using the OS X terminal, then the shell is specified in the Terminal's title bar when you launch it - like so: Terminal - ShellName - 80x24
精彩评论