aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-03-19 14:47:05 +0800
committertypebrook <typebrook@gmail.com>2020-03-19 15:49:18 +0800
commit177ea6791f73c204932fbd4d276a5b63e2aab95f (patch)
tree380f5cf990cac340d14c72aa4beab1240ca869a9
parent5e80314c21f0d28d32920d803583ee65bf35b97d (diff)
Modify behavior for 'gist tag'
- Always print list with tag=true - Let tags align right
-rwxr-xr-xgist6
1 files 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() {
284 [[ $index =~ ^s ]] && extra=$(printf "%-12s" $author)${extra} 284 [[ $index =~ ^s ]] && extra=$(printf "%-12s" $author)${extra}
285 local hashtags=$(_hashtags "$description") 285 local hashtags=$(_hashtags "$description")
286 local description=$(sed -E -e 's/^\[(.+)\]/\\e[33m[\1]\\e[0m/' <<<"$description" | sed "s/ $hashtags$//") 286 local description=$(sed -E -e 's/^\[(.+)\]/\\e[33m[\1]\\e[0m/' <<<"$description" | sed "s/ $hashtags$//")
287 [[ $tag == 'true' ]] && url="$hashtags" && local width=45 287 [[ $tag == 'true' ]] && url="$hashtags" && local width=45 && align=' '
288 288
289 raw_output="$(printf "% 3s" "$index") $(printf "%-${width:-56}s" "$url") $extra $description" 289 raw_output="$(printf "% 3s" "$index") $(printf "%${align:--}${width:-56}s" "$url") $extra $description"
290 decorator=$(( $(grep -o '\\e\[0m' <<<"$raw_output" | wc -l) *9 )) 290 decorator=$(( $(grep -o '\\e\[0m' <<<"$raw_output" | wc -l) *9 ))
291 echo -e "$raw_output" | cut -c -$(( $(tput cols) +decorator )) 291 echo -e "$raw_output" | cut -c -$(( $(tput cols) +decorator ))
292 done 292 done
@@ -667,7 +667,7 @@ _tag_gist() {
667 # if user want to filter gists with given tags 667 # if user want to filter gists with given tags
668 elif [[ -n $1 ]]; then 668 elif [[ -n $1 ]]; then
669 local pattern="($(sed -E 's/([^ ]+)/#\1/g; s/ /|/g' <<<"$@"))" 669 local pattern="($(sed -E 's/([^ ]+)/#\1/g; s/ /|/g' <<<"$@"))"
670 sed -En "/$pattern/ p" $INDEX | hint=false _show_list - 670 sed -En "/$pattern/ p" $INDEX | hint=false tag=true _show_list -
671 else 671 else
672 tag=true _show_list 672 tag=true _show_list
673 fi 673 fi