aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xgist16
1 files changed, 8 insertions, 8 deletions
diff --git a/gist b/gist
index 500097c..92c0484 100755
--- a/gist
+++ b/gist
@@ -56,7 +56,7 @@ configuredClient=""
56GITHUB_API=https://api.github.com 56GITHUB_API=https://api.github.com
57CONFIG=~/.config/gist.conf; mkdir -p ~/.config 57CONFIG=~/.config/gist.conf; mkdir -p ~/.config
58 58
59INDEX_FORMAT=('index' 'url' 'blob_code' 'file_num' 'comment_num' 'author' 'created_at' 'updated_at' 'description') 59INDEX_FORMAT=('index' 'url' 'blob_code' 'file_array' 'file_num' 'comment_num' 'author' 'created_at' 'updated_at' 'description')
60TAG_CHAR='-_[:alnum:]' 60TAG_CHAR='-_[:alnum:]'
61[[ ! -t 0 ]] && INPUT=$(cat) 61[[ ! -t 0 ]] && INPUT=$(cat)
62 62
@@ -300,7 +300,7 @@ _show_list() {
300 local hashtags=$(_hashtags "$description") 300 local hashtags=$(_hashtags "$description")
301 [[ $index =~ ^s ]] && description="$(printf "%-12s" [${author}]) ${description}" 301 [[ $index =~ ^s ]] && description="$(printf "%-12s" [${author}]) ${description}"
302 description=$(sed -E -e 's/^\[(.+)\]/\\e[33m[\1]\\e[0m/' <<<"$description" | sed "s/ $hashtags$//") 302 description=$(sed -E -e 's/^\[(.+)\]/\\e[33m[\1]\\e[0m/' <<<"$description" | sed "s/ $hashtags$//")
303 [[ $tag == 'true' ]] && url="$hashtags" && local width=45 && align=' ' 303 [[ $tag == 'true' ]] && { url="$hashtags"; local width=45; align=' '; extra=''; }
304 304
305 raw_output="$(printf "% 3s" "$index") $(printf "%${align:--}${width:-56}s" "$url") $extra $description" 305 raw_output="$(printf "% 3s" "$index") $(printf "%${align:--}${width:-56}s" "$url") $extra $description"
306 [[ -n $pin ]] && raw_output="$(_color_pinned_tags "$raw_output")" 306 [[ -n $pin ]] && raw_output="$(_color_pinned_tags "$raw_output")"
@@ -349,8 +349,9 @@ _parse_gists() {
349raw = json.load(sys.stdin) 349raw = json.load(sys.stdin)
350for gist in raw: 350for gist in raw:
351 print(gist["html_url"], end=" ") 351 print(gist["html_url"], end=" ")
352 print(",".join(file["raw_url"] for file in gist["files"].values()), end=" ")
353 print(gist["public"], end=" ") 352 print(gist["public"], end=" ")
353 print(",".join(file["raw_url"] for file in gist["files"].values()), end=" ")
354 print(",".join(file["filename"] + "@" + str(file["language"]) for file in gist["files"].values()), end=" ")
354 print(len(gist["files"]), end=" ") 355 print(len(gist["files"]), end=" ")
355 print(gist["comments"], end=" ") 356 print(gist["comments"], end=" ")
356 print(gist["owner"]["login"], end=" ") 357 print(gist["owner"]["login"], end=" ")
@@ -364,7 +365,7 @@ for gist in raw:
364_parse_response() { 365_parse_response() {
365 _parse_gists \ 366 _parse_gists \
366 | tac | nl -s' ' \ 367 | tac | nl -s' ' \
367 | while read -r "${INDEX_FORMAT[@]:0:2}" file_url_array public "${INDEX_FORMAT[@]:3:6}"; do 368 | while read -r "${INDEX_FORMAT[@]:0:2}" public file_url_array "${INDEX_FORMAT[@]:3:7}"; do
368 local blob_code; blob_code=$(echo "$file_url_array" | tr ',' '\n' | sed -E -e 's#.*raw/(.*)/.*#\1#' | sort | cut -c -7 | paste -s -d '-' -) 369 local blob_code; blob_code=$(echo "$file_url_array" | tr ',' '\n' | sed -E -e 's#.*raw/(.*)/.*#\1#' | sort | cut -c -7 | paste -s -d '-' -)
369 local prefix=$mark; [[ $public == 'False' ]] && prefix=p 370 local prefix=$mark; [[ $public == 'False' ]] && prefix=p
370 [[ -n $1 ]] && local index=${1}; index=${prefix}${index} 371 [[ -n $1 ]] && local index=${1}; index=${prefix}${index}
@@ -534,10 +535,9 @@ _show_detail() {
534 echo API : https://api.github.com/gists/$GIST_ID 535 echo API : https://api.github.com/gists/$GIST_ID
535 echo created_at: $created_at 536 echo created_at: $created_at
536 echo updated_at: $updated_at 537 echo updated_at: $updated_at
537 repo=$folder/$GIST_ID 538 echo files:
538 if [[ -d $repo ]]; then 539 echo $file_array | tr ',' '\n' | tr '@' ' ' \
539 echo files:; ls -a $repo | sed -Ee 's/(\.|\.\.|\.git)//g; /^$/ d; s/^/ /' 540 | column -t | sed -e 's/^/ /'
540 fi
541 done 541 done
542} 542}
543 543