From 3046024b29ab3ac0841f0134b00f089824e49cdd Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 16 Aug 2012 14:08:07 +0200 Subject: [PATCH] Adding git untracked files information (branch* instead of branch if so) --- liquidprompt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/liquidprompt b/liquidprompt index de87db1..5fe92d7 100755 --- a/liquidprompt +++ b/liquidprompt @@ -569,6 +569,14 @@ _lp_git_branch_color() git diff --cached --quiet >/dev/null 2>&1 GDC=$? + local has_untracked + has_untracked=$(git status 2>/dev/null | grep '\(# Untracked\)') + if [[ -z "$has_untracked" ]] ; then + has_untracked="" + else + has_untracked="*" + fi + local has_commit has_commit=$(git rev-list --no-merges --count origin/${branch}..${branch} 2>/dev/null) if [[ -z "$has_commit" ]] ; then @@ -579,16 +587,16 @@ _lp_git_branch_color() has_lines=$(git diff --numstat | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d/-%d\n", plus, minus)}') if [[ "$has_commit" -gt "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}$has_commit${NO_COL})" + ret="${LP_COLOR_CHANGES}${branch}${has_untracked}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL},${LP_COLOR_COMMITS}$has_commit${NO_COL})" else - ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL})" # changes to commit + ret="${LP_COLOR_CHANGES}${branch}${has_untracked}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL})" # changes to commit fi else if [[ "$has_commit" -gt "0" ]] ; then # some commit(s) to push - ret="${LP_COLOR_COMMITS}${branch}${NO_COL}(${LP_COLOR_COMMITS}$has_commit${NO_COL})" + ret="${LP_COLOR_COMMITS}${branch}${has_untracked}${NO_COL}(${LP_COLOR_COMMITS}$has_commit${NO_COL})" else - ret="${LP_COLOR_UP}${branch}${NO_COL}" # nothing to commit or push + ret="${LP_COLOR_UP}${branch}${has_untracked}${NO_COL}" # nothing to commit or push fi fi echo -ne "$ret"