From 4c023a2a946746aa874254ba465aeb38792a8533 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Mon, 13 Aug 2012 09:27:14 +0200 Subject: [PATCH 1/3] Fix bug: __battery:local:3: not an identifier: 0: --- liquidprompt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liquidprompt b/liquidprompt index 4d56259..4f99ed3 100755 --- a/liquidprompt +++ b/liquidprompt @@ -626,7 +626,7 @@ __svn_branch_color() __battery() { command -v acpi >/dev/null 2>&1 || return 4; # or no battery support - local acpi=$(acpi --battery 2>/dev/null) + local acpi="$(acpi --battery 2>/dev/null)" local bat=$( echo $acpi | sed "s/^Battery .*, \([0-9]*\)%.*$/\1/") if [[ -z "${bat}" ]] ; then From 0818aa18690aa202f2c6683771944dece47488c7 Mon Sep 17 00:00:00 2001 From: Ludovic Rousseau Date: Mon, 13 Aug 2012 16:16:47 +0200 Subject: [PATCH 2/3] Warn if the shell is not supported If the shell is not recognised as a supported ("bash" and "zsh" for now) then a warning will be displayed in red. For example on Mac OS X the shell process is named "-bash" (note the first character) and is not yet recognised as a valid shell name. --- liquidprompt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/liquidprompt b/liquidprompt index 4f99ed3..f5ca9dd 100755 --- a/liquidprompt +++ b/liquidprompt @@ -884,6 +884,8 @@ prompt_on() LP_OLD_PROMPT_COMMAND="$PROMPT_COMMAND" elif [[ "$WORKING_SHELL" == "zsh" ]]; then LP_OLD_PROMPT_COMMAND="$precmd" + else + echo "${RED}Shell $WORKING_SHELL not supported $NO_COL" fi fi if [[ "$WORKING_SHELL" == "bash" ]]; then From 86f8dba07f5b2de6cba4d6d4535134839aca73e2 Mon Sep 17 00:00:00 2001 From: Ludovic Rousseau Date: Mon, 13 Aug 2012 16:28:07 +0200 Subject: [PATCH 3/3] A login shell starts with a "-" A login shell process is started with a "-" as the first character in the process name. It is the case with Terminal on Mac OS X. See http://docstore.mik.ua/orelly/unix/upt/ch51_09.htm --- liquidprompt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/liquidprompt b/liquidprompt index f5ca9dd..78283f0 100755 --- a/liquidprompt +++ b/liquidprompt @@ -39,6 +39,11 @@ WORKING_SHELL=$(ps -p $$ | tail -n1 | awk '{print $NF}') +# A login shell starts with a "-" +if [[ "$WORKING_SHELL" == "-bash" ]]; then + WORKING_SHELL="bash" +fi + if [[ "$WORKING_SHELL" == "bash" ]]; then # Check for recent enough version of bash. [[ -z "$BASH_VERSION" || -z "$PS1" || -z "$TERM" ]] && return;