/* Code-Comments */

Determine Which Shell Is Currently Running

December 03, 2019

If you switch between shells, it might be handy to determine which one is currently running.

One way to do that is to check your process status (ps utility).

To find the process id (PID) of the current instance of your shell, use:

$ echo "$$"

You can then pass this into the ps utility to find a specific PID with the -p flag:

$ ps -p "$$"
  PID TTY           TIME CMD
21373 ttys001    0:00.69 -zsh

Stephen Weiss

Thanks for reading! My name's Stephen Weiss. I live in Chicago with my wife, Kate, and dog, Finn.
Click here to see the archives of my weeks in review and sign up yourself!