From a201e152f7e5383864b0aa1931d177d131b3f2ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Sun, 19 Jan 2014 19:56:00 +0100 Subject: [PATCH] hg: remove usage of tail+awk in favor of sed --- liquidprompt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/liquidprompt b/liquidprompt index 5766800..b882c8b 100755 --- a/liquidprompt +++ b/liquidprompt @@ -847,7 +847,8 @@ _lp_hg_branch_color() fi else local has_lines - has_lines=$(hg diff --stat 2>/dev/null | tail -n 1 | awk 'FS=" " {printf("+%s/-%s\n", $4, $6)}') + # Parse the last line of the diffstat-style output + has_lines="$(hg diff --stat 2>/dev/null | sed -n '$ s!^.*, \([0-9]*\) .*, \([0-9]*\).*$!+\1/-\2!p')" if (( commits > 0 )) ; then # Changes to commit and commits to push ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL},${LP_COLOR_COMMITS}$commits${NO_COL})${has_untracked}${NO_COL}"