diff --git a/README.md b/README.md index 9a4416e..e2b58a7 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,8 @@ preserving the first two directories; (git, mercurial, subversion, bazaar or fossil), in green if everything is up to date, in red if there are changes, in yellow if there are pending commits to push; -* the number of added/deleted lines (git) or files (fossil), if -changes have been made and the number of pending commits, if any; +* the number of added/deleted lines if changes have been made and the +number of pending commits, if any; * a yellow plus if there is stashed modifications; * a red star if there is some untracked files in the repository; * the error code of the last command, if it has failed in some way; @@ -338,4 +338,3 @@ limitation of the Subversion versionning model. (like xterm-256) * The analog clock necessitate a unicode-aware terminal and a sufficiently complete font. - diff --git a/liquidprompt b/liquidprompt index 7227de4..afe5204 100755 --- a/liquidprompt +++ b/liquidprompt @@ -29,7 +29,7 @@ # Brendan Fahy # postfix variable # Clément Mathieu # Bazaar support # David Loureiro # small portability fix -# Étienne Deparis # Fossil support +# Étienne Deparis # Fossil support # Florian Le Frioux # Use ± mark when root in VCS dir. # François Schmidts # small code fix, _lp_get_dirtrim # Frédéric Lepied # Python virtual env @@ -908,23 +908,54 @@ _lp_fossil_branch_color() local C2E # Modified files (added or edited) local C2D # Deleted files local C2A # Extras files + local C2AA # Added files + local PLUSLINE # Added lines + local MINUSLINE # Deleted lines local ret C2E=$(fossil changes | wc -l) - C2D=$(fossil changes | grep DELETED | wc -l) - let "C2E = $C2E - $C2D" C2A=$(fossil extras | wc -l) + PLUSLINE=$(fossil diff | egrep '^\+[^+].+$' | wc -l) + MINUSLINE=$(fossil diff | egrep '^-[^-].+$' | wc -l) ret="" - if [[ "$C2E" -gt 0 ]] ; then - ret+="+$C2E" + C2AA=`fossil changes | grep ADDED | wc -l` + if [[ $C2AA -gt 0 ]] ; then + # We count the line "à la" git + local ADDFILE + local FILE + ADDFILE=`fossil changes | grep ADDED | sed -e 's/\s\{2,\}/ /g' | cut -d" " -f2` + for FILE in $ADDFILE ; do + PLULI=$(wc -l $FILE | cut -d" " -f1) + let PLUSLINE=$PLUSLINE+$PLULI + done + fi + + if [[ $PLUSLINE -gt 0 ]] ; then + ret+="+$PLUSLINE" + fi + + C2D=`fossil changes | grep DELETED | wc -l` + if [[ $C2D -gt 0 ]] ; then + # We count the line "à la" git + local DELFILE + local FILE + DELFILE=`fossil changes | grep DELETED | sed -e 's/\s\{2,\}/ /g' | cut -d" " -f2` + for FILE in $DELFILE ; do + MINLI=$(wc -l $FILE | cut -d" " -f1) + let MINUSLINE=$MINUSLINE+$MINLI + done + fi + + if [[ $MINUSLINE -gt 0 ]] ; then + if [[ "$ret" = "" ]] ; then + ret+="-$MINUSLINE" + else + ret+="/-$MINUSLINE" + fi fi - if [[ "$C2D" -gt 0 ]] ; then - if [[ "$ret" = "" ]] ; then - ret+="-$C2D" - else - ret+="/-$C2D" - fi + if [[ "$C2E" -gt 0 ]] ; then + ret+=" in $C2E" fi if [[ "$C2A" -gt 0 ]] ; then