Created
April 22, 2012 06:50
-
-
Save antonjn/2462122 to your computer and use it in GitHub Desktop.
Which shell do I use? (mac)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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