Which shell I am using in mac

To see what shell is currently running – which may or may not be your default shell – use:

# Prints something like '/bin/ksh' or '-zsh'
# See bottom section if you always need the full path.
ps -o comm= $$

The above assumes that the running shell is a POSIX-compatible shell. If the running shell is PowerShell, replace $$ with $PID, which will tell you the full path even if PowerShell is also the default shell. If you use
(Get-Process -Id $PID).Path instead, you’ll get the full path with symlinks resolved, if any.

To see what shell is your default shell, run:

echo $SHELL

If the currently running shell is PowerShell: $env:SHELL


If you need to know the full path of the currently running shell:

If the current shell was launched directly by Terminal.app (or iTerm2), it is a login shell launched via the login utility, which causes the current shell process to self-report its binary abstractly as -<binary-filename>, e.g. -zsh; that is, you don’t get the full path of the binary underlying the shell process.

If always obtaining the full path is required – e.g. if you want to distinguish the system Bash /bin/bash from a later version installed via Homebrew – you can use the following command line:

(bin="$(ps -o comm= $$)"; expr "$bin" : '\(-\)' >/dev/null && bin="$(ps -o command= $PPID | grep -Eo ' SHELL=[^ ]+' | cut -f 2- -d =)"; [ -n "$bin" ] && echo "$bin" || echo "$SHELL")

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)