diff options
| author | Hsieh Chin Fan <typebrook@gmail.com> | 2020-07-03 12:56:11 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <typebrook@gmail.com> | 2020-07-03 13:17:24 +0800 |
| commit | be46fcdede28283ee33dbfe1d817c9f592a596a2 (patch) | |
| tree | 4bc27d10016e6fac348714e12e8b70fe22ed71e5 | |
| parent | ce5ee2bf1b3571f6e2bd14996ecc78f364794d22 (diff) | |
Refine speed of coloring tags
| -rwxr-xr-x | gist | 13 |
1 files changed, 8 insertions, 5 deletions
| @@ -322,10 +322,6 @@ _print_records() { | |||
| 322 | if [[ $display == 'tag' ]]; then | 322 | if [[ $display == 'tag' ]]; then |
| 323 | [[ $show_untagged == 'false' && tags_string == ',' ]] && continue | 323 | [[ $show_untagged == 'false' && tags_string == ',' ]] && continue |
| 324 | message="$(printf '% 45s' "${tags_string//,/ }") " | 324 | message="$(printf '% 45s' "${tags_string//,/ }") " |
| 325 | if [[ -n $pin ]]; then | ||
| 326 | local pinned_tags=($pin); local pattern="$(_pattern_pinned_tags ${pinned_tags[@]/#/#})" | ||
| 327 | message="$(_color_pattern "$pattern" <<<"$message")" | ||
| 328 | fi | ||
| 329 | elif [[ $display == 'language' ]]; then | 325 | elif [[ $display == 'language' ]]; then |
| 330 | message="$(tr ',' '\n' <<< $file_array | sed -Ee 's/.+=/#/' | uniq | xargs)" | 326 | message="$(tr ',' '\n' <<< $file_array | sed -Ee 's/.+=/#/' | uniq | xargs)" |
| 331 | message="$(printf '% 45s' "$message")" | 327 | message="$(printf '% 45s' "$message")" |
| @@ -338,7 +334,14 @@ _print_records() { | |||
| 338 | raw_output="$(printf "%-3s" "$index") $message $extra ${status:+${status} }$(_color_pattern '^(\[.+\])' <<<"$description")" | 334 | raw_output="$(printf "%-3s" "$index") $message $extra ${status:+${status} }$(_color_pattern '^(\[.+\])' <<<"$description")" |
| 339 | decorator=$(( $(grep -o '\\e\[0m' <<<"$raw_output" | wc -l) *9 )) | 335 | decorator=$(( $(grep -o '\\e\[0m' <<<"$raw_output" | wc -l) *9 )) |
| 340 | echo -e "$raw_output" | cut -c -$(( $COLUMNS +decorator )) | 336 | echo -e "$raw_output" | cut -c -$(( $COLUMNS +decorator )) |
| 341 | done | 337 | done \ |
| 338 | | if [[ $display == 'tag' && -n $pin ]]; then | ||
| 339 | local pinned_tags=($pin); local pattern="$(_pattern_pinned_tags ${pinned_tags[@]/#/#})" | ||
| 340 | echo -e "$(_color_pattern "$pattern")" | ||
| 341 | else | ||
| 342 | cat | ||
| 343 | fi | ||
| 344 | |||
| 342 | 345 | ||
| 343 | [[ -z $INPUT ]] && _show_hint || true | 346 | [[ -z $INPUT ]] && _show_hint || true |
| 344 | } | 347 | } |