diff options
| author | typebrook <typebrook@gmail.com> | 2020-03-18 15:34:10 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-03-18 15:40:24 +0800 |
| commit | 9fe26b4cfc57a691603b8c790b2daf15e8b3f738 (patch) | |
| tree | 7354dbdb6084c8ff4770392fb6cb00feba7c0063 | |
| parent | 6262a78bea9417c8099d8774f2b8a27ee5406976 (diff) | |
Modify sub-commands for tags
- 'gist tag' to show gist list without url but tags insdead
- 'gist tags' to list existing tags
| -rwxr-xr-x | gist | 20 |
1 files changed, 14 insertions, 6 deletions
| @@ -283,9 +283,11 @@ _show_list() { | |||
| 283 | local extra; extra=$(_check_repo_status "$repo" "$blob_code") | 283 | local extra; extra=$(_check_repo_status "$repo" "$blob_code") |
| 284 | [[ -z $extra ]] && extra="$file_num $comment_num" | 284 | [[ -z $extra ]] && extra="$file_num $comment_num" |
| 285 | [[ $index =~ ^s ]] && extra=$(printf "%-12s" $author)${extra} | 285 | [[ $index =~ ^s ]] && extra=$(printf "%-12s" $author)${extra} |
| 286 | description=$(echo $description | sed -E -e 's/\[(.+)\]/\\e[33m[\1]\\e[0m/') | 286 | hashtags=$(_hashtags "$description") |
| 287 | description=$(sed -E -e 's/\[(.+)\]/\\e[33m[\1]\\e[0m/' <<<"$description" | sed "s/ $hashtags$//") | ||
| 288 | [[ $tag == 'true' ]] && url="$hashtags" && local width=45 | ||
| 287 | 289 | ||
| 288 | echo -e "$(printf "% 3s" "$index") $(printf "%-56s" "$url") $extra $description" \ | 290 | echo -e "$(printf "% 3s" "$index") $(printf "%-${width:-56}s" "$url") $extra $description" \ |
| 289 | | cut -c -"$(tput cols)" | 291 | | cut -c -"$(tput cols)" |
| 290 | done | 292 | done |
| 291 | 293 | ||
| @@ -668,13 +670,17 @@ _tag_gist() { | |||
| 668 | local pattern="($(sed -E 's/([^ ]+)/#\1/g; s/ /|/g' <<<"$@"))" | 670 | local pattern="($(sed -E 's/([^ ]+)/#\1/g; s/ /|/g' <<<"$@"))" |
| 669 | sed -En "/$pattern/ p" $INDEX | hint=false _show_list - | 671 | sed -En "/$pattern/ p" $INDEX | hint=false _show_list - |
| 670 | else | 672 | else |
| 671 | while read -r "${INDEX_FORMAT[@]}"; do | 673 | tag=true _show_list |
| 672 | _hashtags "$description" | tr ' ' '\n' | sed -e '/^$/d' | ||
| 673 | done < $INDEX \ | ||
| 674 | | sort -u | ||
| 675 | fi | 674 | fi |
| 676 | } | 675 | } |
| 677 | 676 | ||
| 677 | _show_tags() { | ||
| 678 | while read -r "${INDEX_FORMAT[@]}"; do | ||
| 679 | _hashtags "$description" | tr ' ' '\n' | sed -e '/^$/d' | ||
| 680 | done < $INDEX \ | ||
| 681 | | sort -u | ||
| 682 | } | ||
| 683 | |||
| 678 | _apply_config "$@" || exit 1 | 684 | _apply_config "$@" || exit 1 |
| 679 | getConfiguredClient || exit 1 | 685 | getConfiguredClient || exit 1 |
| 680 | if [[ $init ]]; then _fetch_gists; exit 0; fi | 686 | if [[ $init ]]; then _fetch_gists; exit 0; fi |
| @@ -719,6 +725,8 @@ case "$1" in | |||
| 719 | tag | t) | 725 | tag | t) |
| 720 | shift | 726 | shift |
| 721 | _tag_gist "$@" ;; | 727 | _tag_gist "$@" ;; |
| 728 | tags) | ||
| 729 | _show_tags ;; | ||
| 722 | version) | 730 | version) |
| 723 | echo "Version $currentVersion" ;; | 731 | echo "Version $currentVersion" ;; |
| 724 | update) | 732 | update) |