aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHsieh Chin Fan <typebrook@gmail.com>2020-07-03 02:17:01 +0800
committerHsieh Chin Fan <typebrook@gmail.com>2020-07-03 02:17:01 +0800
commite6b15fe1c658ad0577ee933ef5d6e34a8cea6b74 (patch)
treebea2d266d6958a3fff6abf8fe2f4a093035d10e1
parentad26de81576a733858042513a39d25fd89c7b085 (diff)
Refine print method
-rwxr-xr-xgist21
1 files changed, 10 insertions, 11 deletions
diff --git a/gist b/gist
index 3f6b3ba..7910439 100755
--- a/gist
+++ b/gist
@@ -318,25 +318,24 @@ _print_records() {
318 318
319 sed -Ee "/^$mark/ !d; /^$(_index_pattern) / !d" $INDEX \ 319 sed -Ee "/^$mark/ !d; /^$(_index_pattern) / !d" $INDEX \
320 | while read -r "${INDEX_FORMAT[@]}"; do 320 | while read -r "${INDEX_FORMAT[@]}"; do
321 local message=${GIST_DOMAIN}/${gist_id} 321 local message="$(printf '%-56s' ${GIST_DOMAIN}/${gist_id})"
322 if [[ $display == 'tag' ]]; then 322 if [[ $display == 'tag' ]]; then
323 local tags=( ${tags_string//,/ } ); message="${tags[@]}" 323 [[ $show_untagged == 'false' && tags_string == ',' ]] && continue
324 [[ $show_untagged == 'false' && ${#tags[@]} == '0' ]] && continue 324 message="$(printf '% 45s' "${tags_string//,/ }") "
325 local width=45; local align=' '; 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
326 elif [[ $display == 'language' ]]; then 329 elif [[ $display == 'language' ]]; then
327 message="$(tr ',' '\n' <<< $file_array | sed -Ee 's/.+@/#/' | uniq | xargs)" 330 message="$(tr ',' '\n' <<< $file_array | sed -Ee 's/.+=/#/' | uniq | xargs)"
328 local width=45; local align=' '; 331 message="$(printf '% 45s' "$message")"
329 fi 332 fi
330 333
331 local extra="$(printf "%-4s" "$file_num $comment_num")" 334 local extra="$(printf "%-4s" "$file_num $comment_num")"
332 local status=''; status=$(_check_repo_status "${folder}/${gist_id}" "$blob_code") 335 local status=''; status=$(_check_repo_status "${folder}/${gist_id}" "$blob_code")
333 [[ $index =~ ^s ]] && description="$(printf "%-12s" [${author}]) ${description}" 336 [[ $index =~ ^s ]] && description="$(printf "%-12s" [${author}]) ${description}"
334 337
335 raw_output="$(printf "%-3s" "$index") $(printf "%${align:--}${width:-56}s" "$message") $extra ${status:+${status} }$(_color_pattern '^(\[.+\])' <<<"$description")" 338 raw_output="$(printf "%-3s" "$index") $message $extra ${status:+${status} }$(_color_pattern '^(\[.+\])' <<<"$description")"
336 if [[ -n $pin && $display == 'tag' ]]; then
337 local pinned_tags=($pin); local pattern="$(_pattern_pinned_tags ${pinned_tags[@]/#/#})"
338 raw_output="$(_color_pattern "$pattern" <<<"$raw_output")"
339 fi
340 decorator=$(( $(grep -o '\\e\[0m' <<<"$raw_output" | wc -l) *9 )) 339 decorator=$(( $(grep -o '\\e\[0m' <<<"$raw_output" | wc -l) *9 ))
341 echo -e "$raw_output" | cut -c -$(( $COLUMNS +decorator )) 340 echo -e "$raw_output" | cut -c -$(( $COLUMNS +decorator ))
342 done 341 done