From 177ea6791f73c204932fbd4d276a5b63e2aab95f Mon Sep 17 00:00:00 2001 From: typebrook Date: Thu, 19 Mar 2020 14:47:05 +0800 Subject: Modify behavior for 'gist tag' - Always print list with tag=true - Let tags align right --- gist | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gist b/gist index 9ed2a2c..9363511 100755 --- a/gist +++ b/gist @@ -284,9 +284,9 @@ _show_list() { [[ $index =~ ^s ]] && extra=$(printf "%-12s" $author)${extra} local hashtags=$(_hashtags "$description") local description=$(sed -E -e 's/^\[(.+)\]/\\e[33m[\1]\\e[0m/' <<<"$description" | sed "s/ $hashtags$//") - [[ $tag == 'true' ]] && url="$hashtags" && local width=45 + [[ $tag == 'true' ]] && url="$hashtags" && local width=45 && align=' ' - raw_output="$(printf "% 3s" "$index") $(printf "%-${width:-56}s" "$url") $extra $description" + raw_output="$(printf "% 3s" "$index") $(printf "%${align:--}${width:-56}s" "$url") $extra $description" decorator=$(( $(grep -o '\\e\[0m' <<<"$raw_output" | wc -l) *9 )) echo -e "$raw_output" | cut -c -$(( $(tput cols) +decorator )) done @@ -667,7 +667,7 @@ _tag_gist() { # if user want to filter gists with given tags elif [[ -n $1 ]]; then local pattern="($(sed -E 's/([^ ]+)/#\1/g; s/ /|/g' <<<"$@"))" - sed -En "/$pattern/ p" $INDEX | hint=false _show_list - + sed -En "/$pattern/ p" $INDEX | hint=false tag=true _show_list - else tag=true _show_list fi -- cgit v1.2.3-70-g09d2