From e1620dd4ac46ba88eb9844b32b05e1f76088de58 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sat, 4 Mar 2017 18:37:30 +0100 Subject: [PATCH] fix small bug when printing diff --- git-recall | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/git-recall b/git-recall index 9640170..c882e19 100644 --- a/git-recall +++ b/git-recall @@ -26,7 +26,7 @@ COMMITS="" COMMITS_UNCOL=() # commits without colors LESSKEY=false SED_BIN="" # Sed option to use according OS. -VERSION="1.1.8" +VERSION="1.1.9" # Are we in a git repo? if [[ ! -d ".git" ]] && ! git rev-parse --git-dir &>/dev/null; then @@ -182,7 +182,8 @@ function get_diff() { DIFF_TIP=${ELT:0:7} DIFF_CMD="git show $DIFF_TIP --color=always" DIFF=$(eval ${DIFF_CMD} 2>/dev/null) - off=$(echo "$DIFF" | grep -c ".\{$CN\}") #Number of lines in the diff that are longer than terminal width. + tmp_diff="$(echo "$DIFF" | $SED_BIN "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")" # remove colors escape codes + off=$(echo "$tmp_diff" | grep -c ".\{$CN\}") #Number of lines in the diff that are longer than terminal width. DIFF_LINES_NUMBER="$(echo "$DIFF" | wc -l)" DIFF_LINES_NUMBER=$(( DIFF_LINES_NUMBER + off )) }