Skip to content

Instantly share code, notes, and snippets.

@antonjn
Created April 22, 2012 06:50
Show Gist options
  • Save antonjn/2462122 to your computer and use it in GitHub Desktop.
Save antonjn/2462122 to your computer and use it in GitHub Desktop.
Which shell do I use? (mac)
# get_shell
#
# This will work when called in a function and in functions calling functions etc.
# The function uses ps(1) to find out which shell is used. The following table
# shows the shell names used to distinguse them (mac osx).
#
# Shells: bash | bash | sh | ksh | csh | tcsh | zsh |
# Shells (ps): bash |-bash | sh | ksh | -sh | -csh | zsh |
#
get_shell() {
ps -o command | grep -P "^(?:-bash|bash|sh|ksh|-sh|-csh|zsh)$" | tail -n 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment