Merge pull request #35 from dolmen/fix/WORKING_SHELL

Fix shell detection
This commit is contained in:
nojhan 2012-08-14 03:18:53 -07:00
commit 9f06ebe883

View File

@ -37,17 +37,8 @@
# See the README.md file for a summary of features. # See the README.md file for a summary of features.
_LP_WORKING_SHELL=${SHELL##*/} # Check for recent enough version of bash.
if test -n "$BASH_VERSION" -a -n "$PS1" -a -n "$TERM" ; then
# A login shell starts with a "-"
if [[ "$_LP_WORKING_SHELL" == "-bash" ]]; then
_LP_WORKING_SHELL="bash"
fi
if [[ "$_LP_WORKING_SHELL" == "bash" ]]; then
# Check for recent enough version of bash.
[[ -z "$BASH_VERSION" || -z "$PS1" || -z "$TERM" ]] && return;
bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.} bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.}
if [[ $bmajor -lt 3 ]] || [[ $bmajor -eq 3 && $bminor -lt 2 ]]; then if [[ $bmajor -lt 3 ]] || [[ $bmajor -eq 3 && $bminor -lt 2 ]]; then
unset bash bmajor bminor unset bash bmajor bminor
@ -55,15 +46,20 @@ if [[ "$_LP_WORKING_SHELL" == "bash" ]]; then
fi fi
unset bash bmajor bminor unset bash bmajor bminor
_LP_WORKING_SHELL=bash
_LP_OPEN_ESC="\[" _LP_OPEN_ESC="\["
_LP_CLOSE_ESC="\]" _LP_CLOSE_ESC="\]"
_LP_USER_SYMBOL="\u" _LP_USER_SYMBOL="\u"
_LP_HOST_SYMBOL="\h" _LP_HOST_SYMBOL="\h"
elif [[ "$_LP_WORKING_SHELL" == "zsh" ]]; then elif test -n "$ZSH_VERSION" ; then
_LP_WORKING_SHELL=zsh
_LP_OPEN_ESC="%{" _LP_OPEN_ESC="%{"
_LP_CLOSE_ESC="%}" _LP_CLOSE_ESC="%}"
_LP_USER_SYMBOL="%n" _LP_USER_SYMBOL="%n"
_LP_HOST_SYMBOL="%m" _LP_HOST_SYMBOL="%m"
else
echo "liquidprompt: shell not supported" >&2
return
fi fi
@ -963,8 +959,6 @@ prompt_on()
LP_OLD_PROMPT_COMMAND="$PROMPT_COMMAND" LP_OLD_PROMPT_COMMAND="$PROMPT_COMMAND"
elif [[ "$_LP_WORKING_SHELL" == "zsh" ]]; then elif [[ "$_LP_WORKING_SHELL" == "zsh" ]]; then
LP_OLD_PROMPT_COMMAND="$precmd" LP_OLD_PROMPT_COMMAND="$precmd"
else
echo "${RED}Shell $_LP_WORKING_SHELL not supported $NO_COL"
fi fi
fi fi
if [[ "$_LP_WORKING_SHELL" == "bash" ]]; then if [[ "$_LP_WORKING_SHELL" == "bash" ]]; then