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")
chsh
? Or, at least, restart your terminal. – Shivaree$o
does in your 2nd command - what is the value of$o
? – Advertisementzsh
and its path in/etc/shells
? – Trammell.zshrc
file is being ran? I don't see my aliases working as of right now... – Catanzaro