From e883c8e41dc13b7ced12fe4a41b04aaccbbb33f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Fri, 27 Dec 2013 19:14:48 +0100 Subject: [PATCH] Fix more bad code for LP_ENABLE_TITLE Fix one more portability hack that was really inefficient. --- liquidprompt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/liquidprompt b/liquidprompt index 33b2844..088a37b 100755 --- a/liquidprompt +++ b/liquidprompt @@ -106,6 +106,11 @@ case "$LP_OS" in SunOS) _lp_CPUNUM=$( kstat -m cpu_info | grep -c "module: cpu_info" ) ;; esac +# Extended regexp patterns for sed +# GNU/BSD sed +_LP_SED_EXTENDED=r +[[ "$LP_OS" = Darwin ]] && _LP_SED_EXTENDED=E + # get current load case "$LP_OS" in @@ -1471,11 +1476,8 @@ _lp_temperature() { _lp_as_text() { # Remove colors from the computed prompt - case "$LP_OS" in - Linux|FreeBSD|OpenBSD|SunOS) local pst="$(echo $1 | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")" ;; - Darwin) local pst="$(echo $1 | sed -E "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")" ;; - esac - + local pst + pst="$(echo "$1" | sed -$_LP_SED_EXTENDED "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")" # Remove escape sequences # FIXME check the zsh compatibility