From be46fcdede28283ee33dbfe1d817c9f592a596a2 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Fri, 3 Jul 2020 12:56:11 +0800 Subject: Refine speed of coloring tags --- gist | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gist b/gist index 34158f2..74c6339 100755 --- a/gist +++ b/gist @@ -322,10 +322,6 @@ _print_records() { if [[ $display == 'tag' ]]; then [[ $show_untagged == 'false' && tags_string == ',' ]] && continue message="$(printf '% 45s' "${tags_string//,/ }") " - if [[ -n $pin ]]; then - local pinned_tags=($pin); local pattern="$(_pattern_pinned_tags ${pinned_tags[@]/#/#})" - message="$(_color_pattern "$pattern" <<<"$message")" - fi elif [[ $display == 'language' ]]; then message="$(tr ',' '\n' <<< $file_array | sed -Ee 's/.+=/#/' | uniq | xargs)" message="$(printf '% 45s' "$message")" @@ -338,7 +334,14 @@ _print_records() { raw_output="$(printf "%-3s" "$index") $message $extra ${status:+${status} }$(_color_pattern '^(\[.+\])' <<<"$description")" decorator=$(( $(grep -o '\\e\[0m' <<<"$raw_output" | wc -l) *9 )) echo -e "$raw_output" | cut -c -$(( $COLUMNS +decorator )) - done + done \ + | if [[ $display == 'tag' && -n $pin ]]; then + local pinned_tags=($pin); local pattern="$(_pattern_pinned_tags ${pinned_tags[@]/#/#})" + echo -e "$(_color_pattern "$pattern")" + else + cat + fi + [[ -z $INPUT ]] && _show_hint || true } -- cgit v1.2.3-70-g09d2