From 48657936432fbbea797c4822234f41f739fd05e9 Mon Sep 17 00:00:00 2001 From: typebrook Date: Sun, 17 May 2020 00:57:15 +0800 Subject: Add pagnation to fetch even if user's gists >100 --- gist | 75 +++++++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/gist b/gist index fe3ee42..b9cb192 100755 --- a/gist +++ b/gist @@ -58,6 +58,7 @@ configuredClient="" NAME=${GISTSCRIPT:-$(basename $0)} #show hint and helper message with current script name GITHUB_API=https://api.github.com CONFIG=~/.config/gist.conf; mkdir -p ~/.config +per_page=100 INDEX_FORMAT=('index' 'url' 'tags_string' 'blob_code' 'file_array' 'file_num' 'comment_num' 'author' 'created_at' 'updated_at' 'description') TAG_CHAR='-_[:alnum:]' @@ -125,7 +126,7 @@ http_method() { case "$configuredClient" in curl) [[ -n $token ]] && header_opt="--header" header="Authorization: token $token" [[ $METHOD =~ (POST|PATCH) ]] && data_opt='--data' - curl -X "$METHOD" -A curl -s $header_opt "$header" $data_opt "@$http_data" "$@" ;; + curl -X "$METHOD" -A curl -s $header_opt "$header" $data_opt ${HEADER:+-D $HEADER} "@$http_data" "$@" ;; wget) [[ -n $token ]] && header_opt="--header" header="Authorization: token $token" [[ $METHOD =~ (POST|PATCH) ]] && data_opt='--body-file' wget --method="$METHOD" -qO- $header_opt "$header" $data_opt "$http_data" "$@" ;; @@ -356,29 +357,30 @@ _grep_content() { # Parse JSON object of the result of gist fetch _parse_gists() { - _process_json ' + _process_json ' raw = json.load(sys.stdin) for gist in raw: - print(gist["html_url"], end=" ") - print(gist["public"], end=" ") - print(",".join(file["raw_url"] for file in gist["files"].values()), end=" ") - print(",".join(file["filename"].replace(" ", "-") + "@" + str(file["language"]).replace(" ", "-") for file in gist["files"].values()), end=" ") - print(len(gist["files"]), end=" ") - print(gist["comments"], end=" ") - print(gist["owner"]["login"], end=" ") - print(gist["created_at"], end=" ") - print(gist["updated_at"], end=" ") - print(gist["description"]) - ' + print(gist["html_url"], end=" ") + print(gist["public"], end=" ") + print(",".join(file["raw_url"] for file in gist["files"].values()), end=" ") + print(",".join(file["filename"].replace(" ", "-") + "@" + str(file["language"]).replace(" ", "-") for file in gist["files"].values()), end=" ") + print(len(gist["files"]), end=" ") + print(gist["comments"], end=" ") + print(gist["owner"]["login"], end=" ") + print(gist["created_at"], end=" ") + print(gist["updated_at"], end=" ") + print(gist["description"]) + ' } # Parse response from 'gist fetch' to the format for index file _parse_response() { + local num=$start_from_num _parse_gists \ | tac | nl -s' ' \ | while read -r "${INDEX_FORMAT[@]:0:2}" public file_url_array "${INDEX_FORMAT[@]:4:7}"; do local private_prefix=''; [[ $public == 'False' ]] && private_prefix=p - [[ -n $1 ]] && local index=${1}; index=${private_prefix}${prefix}${index} + [[ -n $num ]] && local index=${num} && num=$(($num+1)); index=${private_prefix}${prefix}${index} local blob_code=$(echo "$file_url_array" | tr ',' '\n' | sed -E -e 's#.*raw/(.*)/.*#\1#' | sort | cut -c -7 | paste -s -d '-' -) file_array=${file_array//@None/@Text} @@ -393,27 +395,45 @@ _parse_response() { } # Get latest list of gists from Github API -# TODO pagnation for more than 100 gists _fetch_gists() { - echo "fetching $user's gists from $GITHUB_API..." - echo local route="users/$user/gists" local prifix='' if [[ $mark == s ]]; then route='gists/starred' prefix=s - extra="s0 https://gist.github.com/b0d2e7e67aa50298fdf8111ae7466b56 #bash,#gist NONE README.md@Markdown,gist@Shell 2 30 typebrook 2019-12-26T06:49:40Z 2020-05-15T13:00:31Z [bash-gist] A bash script for gist management" fi - result=$(http_method GET $GITHUB_API/$route?per_page=100 | prefix=$prefix _parse_response) - result=$(printf "${extra:+$extra\n}$result") - [[ -z $result ]] && echo 'Not a single valid gist' && return 0 + # set global variable HEADER in http_method, so prevent using pipe + HEADER=$(tmp_file HEADER) + HEADER=$HEADER http_method GET $GITHUB_API/$route${1} | start_from_num=$2 prefix=$prefix _parse_response +} + +# consider if HEADER is not exist +_fetch_gists_with_pagnation() { + echo "fetching $user's gists from $GITHUB_API..." + echo + + local fetched_records=$(tmp_file fetched) + _fetch_gists "?per_page=$per_page" >> $fetched_records + + while true; do + local next_page='' + [[ -e $HEADER ]] && next_page=$(sed -Ene '/^[lL]ink: / s/.+page=([[:digit:]]+)>; rel=\"next\".+/\1/p' $HEADER) + [[ -z $next_page ]] && break + printf "%-4s gists fetched\n" $(( ($next_page -1) * $per_page )) + + _fetch_gists "?per_page=$per_page&page=$next_page" $(( $(wc -l <$fetched_records) +1 )) >> $fetched_records + done || return 1 + + [[ ! -s $fetched_records ]] && echo 'Not a single valid gist' && return 0 - sed -i'' -Ee "/^$mark/ d" $INDEX && echo "$result" >> $INDEX + sed -i'' -Ee "/^$mark/ d" $INDEX; cat $fetched_records >> $INDEX hint=$hint _show_list [[ $auto_sync != false ]] && (_sync_repos &> /dev/null &) true + #extra="s0 https://gist.github.com/b0d2e7e67aa50298fdf8111ae7466b56 #bash,#gist NONE README.md@Markdown,gist@Shell 2 30 typebrook 2019-12-26T06:49:40Z 2020-05-15T13:00:31Z [bash-gist] A bash script for gist management" + #result=$(printf "${extra:+$extra\n}$result") } # Fetch gists for a given user @@ -601,7 +621,8 @@ _push_to_remote() { git add . && git commit -m 'update' fi if [[ -n $(git cherry) ]]; then - git push origin master && (hint=false _fetch_gists &> /dev/null &) + # FIXME only fetch one gist + git push origin master && (hint=false _fetch_gists_with_pagnation &> /dev/null &) fi } @@ -669,7 +690,7 @@ _create_gist() { | _gist_body > "$http_data" \ && http_method POST $GITHUB_API/gists \ | xargs -I{} -0 echo "[{}]" \ - | _parse_response $(( $(sed -e '/^s/ d' $INDEX | wc -l) +1 )) \ + | start_from_num=$(( $(sed -e '/^s/ d' $INDEX | wc -l) +1 )) _parse_response \ | tee -a $INDEX \ | cut -d' ' -f2 | sed -E -e 's#.*/##' \ | (xargs -I{} git clone "$(_repo_url {})" $folder/{} &> /dev/null &) @@ -701,7 +722,7 @@ _edit_gist() { echo '{' \"description\": \""${DESC//\"/\\\"}"\" '}' > "$http_data" new_record=$(http_method PATCH "$GITHUB_API/gists/$GIST_ID" \ | sed -e '1 s/^/[/; $ s/$/]/' \ - | _parse_response "${index#[[:alpha:]]}" ) + | start_from_index="${index#[[:alpha:]]}" _parse_response) [[ -n $new_record ]] && sed -i'' -E -e "/^$index / s^.+^$new_record^" $INDEX \ && hint=false mark="$index " _show_list \ || echo 'Fail to modify gist description' @@ -811,7 +832,7 @@ _access_last_index() { } _apply_config "$@" || exit 1 -if [[ $init ]]; then _fetch_gists; exit 0; fi +if [[ $init ]]; then _fetch_gists_with_pagnation; exit 0; fi case "$1" in "") _show_list ;; @@ -821,7 +842,7 @@ case "$1" in mark=.; _show_list ;; fetch | f) [[ $2 =~ ^(s|star)$ ]] && mark=s || mark=[^s] - _fetch_gists ;; + _fetch_gists_with_pagnation ;; new | n) shift _create_gist "$@" ;; -- cgit v1.2.3-70-g09d2 From d55b5b062ba8380413f3e7860bb4abe6390a310a Mon Sep 17 00:00:00 2001 From: typebrook Date: Sun, 17 May 2020 11:27:56 +0800 Subject: Improve code for update a single gist --- gist | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gist b/gist index b9cb192..6e29fde 100755 --- a/gist +++ b/gist @@ -436,6 +436,13 @@ _fetch_gists_with_pagnation() { #result=$(printf "${extra:+$extra\n}$result") } +# Get a single JSON object of gist from response, and update index file +_update_gist() { + local index=$1 + local record=$(sed -e '1 s/^/[/; $ s/$/]/' | start_from_num="${index#[[:alpha:]]}" _parse_response) + [[ -n $record ]] && sed -i'' -Ee "/^$index / s^.+^$record^" $INDEX +} + # Fetch gists for a given user # TODO pagnation for more than 100 gists _query_user() { @@ -621,8 +628,8 @@ _push_to_remote() { git add . && git commit -m 'update' fi if [[ -n $(git cherry) ]]; then - # FIXME only fetch one gist - git push origin master && (hint=false _fetch_gists_with_pagnation &> /dev/null &) + git push origin master && \ + (http_method GET "$GITHUB_API/gists/$GIST_ID" | _update_gist $1 &> /dev/null &) fi } @@ -720,10 +727,8 @@ _edit_gist() { http_data=$(tmp_file PAYLOAD.EDIT) echo '{' \"description\": \""${DESC//\"/\\\"}"\" '}' > "$http_data" - new_record=$(http_method PATCH "$GITHUB_API/gists/$GIST_ID" \ - | sed -e '1 s/^/[/; $ s/$/]/' \ - | start_from_index="${index#[[:alpha:]]}" _parse_response) - [[ -n $new_record ]] && sed -i'' -E -e "/^$index / s^.+^$new_record^" $INDEX \ + + http_method PATCH "$GITHUB_API/gists/$GIST_ID" | _update_gist $index \ && hint=false mark="$index " _show_list \ || echo 'Fail to modify gist description' } -- cgit v1.2.3-70-g09d2 From 8efa0db70bf12565d3b080194e5e98be4ae49a0e Mon Sep 17 00:00:00 2001 From: typebrook Date: Sun, 17 May 2020 12:58:03 +0800 Subject: Sort gists from oldest to newest --- gist | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gist b/gist index 6e29fde..01c72c7 100755 --- a/gist +++ b/gist @@ -377,7 +377,7 @@ for gist in raw: _parse_response() { local num=$start_from_num _parse_gists \ - | tac | nl -s' ' \ + | nl -s' ' \ | while read -r "${INDEX_FORMAT[@]:0:2}" public file_url_array "${INDEX_FORMAT[@]:4:7}"; do local private_prefix=''; [[ $public == 'False' ]] && private_prefix=p [[ -n $num ]] && local index=${num} && num=$(($num+1)); index=${private_prefix}${prefix}${index} @@ -427,7 +427,8 @@ _fetch_gists_with_pagnation() { [[ ! -s $fetched_records ]] && echo 'Not a single valid gist' && return 0 - sed -i'' -Ee "/^$mark/ d" $INDEX; cat $fetched_records >> $INDEX + sed -i'' -Ee "/^$mark/ d" $INDEX + tac <$fetched_records | nl -s' ' | sed -Ee 's/^ *([^ ]+) ([[:alpha:]]?)[[:digit:]]+/\2\1/' >> $INDEX hint=$hint _show_list [[ $auto_sync != false ]] && (_sync_repos &> /dev/null &) -- cgit v1.2.3-70-g09d2 From 47697ba48a36e43306fc5a5557d2f546c846ac7b Mon Sep 17 00:00:00 2001 From: typebrook Date: Sun, 17 May 2020 14:29:09 +0800 Subject: Refactor method of parsing gists - Do not set indices in _parse_response() unless 'index' is set - Change INDEX_FORMAT --- gist | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/gist b/gist index 01c72c7..a3b54ed 100755 --- a/gist +++ b/gist @@ -60,7 +60,7 @@ GITHUB_API=https://api.github.com CONFIG=~/.config/gist.conf; mkdir -p ~/.config per_page=100 -INDEX_FORMAT=('index' 'url' 'tags_string' 'blob_code' 'file_array' 'file_num' 'comment_num' 'author' 'created_at' 'updated_at' 'description') +INDEX_FORMAT=('index' 'public' 'url' 'tags_string' 'blob_code' 'file_array' 'file_num' 'comment_num' 'author' 'created_at' 'updated_at' 'description') TAG_CHAR='-_[:alnum:]' if [[ ! -t 0 ]]; then INPUT=$(cat) @@ -360,8 +360,8 @@ _parse_gists() { _process_json ' raw = json.load(sys.stdin) for gist in raw: - print(gist["html_url"], end=" ") print(gist["public"], end=" ") + print(gist["html_url"], end=" ") print(",".join(file["raw_url"] for file in gist["files"].values()), end=" ") print(",".join(file["filename"].replace(" ", "-") + "@" + str(file["language"]).replace(" ", "-") for file in gist["files"].values()), end=" ") print(len(gist["files"]), end=" ") @@ -375,13 +375,8 @@ for gist in raw: # Parse response from 'gist fetch' to the format for index file _parse_response() { - local num=$start_from_num _parse_gists \ - | nl -s' ' \ - | while read -r "${INDEX_FORMAT[@]:0:2}" public file_url_array "${INDEX_FORMAT[@]:4:7}"; do - local private_prefix=''; [[ $public == 'False' ]] && private_prefix=p - [[ -n $num ]] && local index=${num} && num=$(($num+1)); index=${private_prefix}${prefix}${index} - + | while read -r "${INDEX_FORMAT[@]:1:2}" file_url_array "${INDEX_FORMAT[@]:5:7}"; do local blob_code=$(echo "$file_url_array" | tr ',' '\n' | sed -E -e 's#.*raw/(.*)/.*#\1#' | sort | cut -c -7 | paste -s -d '-' -) file_array=${file_array//@None/@Text} @@ -397,15 +392,13 @@ _parse_response() { # Get latest list of gists from Github API _fetch_gists() { local route="users/$user/gists" - local prifix='' if [[ $mark == s ]]; then route='gists/starred' - prefix=s fi # set global variable HEADER in http_method, so prevent using pipe HEADER=$(tmp_file HEADER) - HEADER=$HEADER http_method GET $GITHUB_API/$route${1} | start_from_num=$2 prefix=$prefix _parse_response + HEADER=$HEADER http_method GET $GITHUB_API/$route${1} | _parse_response } # consider if HEADER is not exist @@ -422,13 +415,17 @@ _fetch_gists_with_pagnation() { [[ -z $next_page ]] && break printf "%-4s gists fetched\n" $(( ($next_page -1) * $per_page )) - _fetch_gists "?per_page=$per_page&page=$next_page" $(( $(wc -l <$fetched_records) +1 )) >> $fetched_records + _fetch_gists "?per_page=$per_page&page=$next_page" >> $fetched_records done || return 1 [[ ! -s $fetched_records ]] && echo 'Not a single valid gist' && return 0 sed -i'' -Ee "/^$mark/ d" $INDEX - tac <$fetched_records | nl -s' ' | sed -Ee 's/^ *([^ ]+) ([[:alpha:]]?)[[:digit:]]+/\2\1/' >> $INDEX + tac <$fetched_records | nl -s' ' \ + | while read -r "${INDEX_FORMAT[@]:0:2}" extra; do + local prefix=''; [[ $public == False ]] && prefix=p + echo $prefix$index $public $extra + done >> $INDEX hint=$hint _show_list [[ $auto_sync != false ]] && (_sync_repos &> /dev/null &) @@ -439,9 +436,8 @@ _fetch_gists_with_pagnation() { # Get a single JSON object of gist from response, and update index file _update_gist() { - local index=$1 - local record=$(sed -e '1 s/^/[/; $ s/$/]/' | start_from_num="${index#[[:alpha:]]}" _parse_response) - [[ -n $record ]] && sed -i'' -Ee "/^$index / s^.+^$record^" $INDEX + local record="$(sed -e '1 s/^/[/; $ s/$/]/' | index=$1 _parse_response)" + [[ -n $record ]] && sed -i'' -Ee "/^$1 / s^.+^$record^" $INDEX } # Fetch gists for a given user @@ -478,7 +474,7 @@ _pull_if_needed() { # Update local git repos _sync_repos() { comm -1 <(ls -A "$folder" | sort) \ - <(cut -d' ' -f1-2 < "$INDEX" | sed -ne "/^$mark/ s#.*/##p" | sort) \ + <(while read -r ${INDEX_FORMAT[@]}; do echo $index $url; done < "$INDEX" | sed -ne "/^$mark/ s#.*/##p" | sort) \ | { result=$(cat) @@ -505,7 +501,8 @@ _repo_url() { # Get gist id from index files _gist_id() { - GIST_ID=$(sed -En -e "/^$1 / s#^$1 [^ ]+/([[:alnum:]]+) .+#\1#p" $INDEX | head -1) + read -r ${INDEX_FORMAT[@]} <<<"$(sed -ne "/$1 / p" $INDEX)" + GIST_ID=${url##*/} if [[ -z $GIST_ID || ! $1 =~ [0-9a-z]+ ]]; then echo -e "$(hint=false _show_list | sed -Ee 's/^( *[0-9a-z]+)/\\e[5m\1\\e[0m/')" echo @@ -574,7 +571,7 @@ _delete_gist() { # Remove repos which are not in index file anymore _clean_repos() { comm -23 <(find $folder -maxdepth 1 -type d | sed -e '1d; s#.*/##' | sort) \ - <(cut -d' ' -f2 < "$INDEX" | sed -e 's#.*/##' | sort 2> /dev/null ) \ + <(while read -r ${INDEX_FORMAT[@]}; do echo $url; done < "$INDEX" | sed -e 's#.*/##' | sort 2> /dev/null ) \ | while read -r dir; do mv $folder/"$dir" /tmp && echo $folder/"$dir" is moved to /tmp done @@ -691,17 +688,20 @@ _create_gist() { _set_gist "$@" || return 1 [[ -z ${files[*]} ]] && files+=($(_new_file "$filename")) [[ -z $description ]] && read -e -r -p 'Type description: ' description < /dev/tty + local index=$([[ $public == False ]] && echo p)$(( $(sed -e '/^s/ d' $INDEX | wc -l) +1 )) echo 'Creating a new gist...' http_data=$(tmp_file PATLOAD.CREATE) echo -e "${files[*]}\n$description" \ | _gist_body > "$http_data" \ && http_method POST $GITHUB_API/gists \ - | xargs -I{} -0 echo "[{}]" \ - | start_from_num=$(( $(sed -e '/^s/ d' $INDEX | wc -l) +1 )) _parse_response \ + | sed -e '1 s/^/\[/; $ s/$/\]/' \ + | index=$index _parse_response \ | tee -a $INDEX \ - | cut -d' ' -f2 | sed -E -e 's#.*/##' \ - | (xargs -I{} git clone "$(_repo_url {})" $folder/{} &> /dev/null &) + | while read -r "${INDEX_FORMAT[@]}"; do + local gist_id=${url/##*/} + (git clone "$(_repo_url $gist_id)" $folder/$gist_id &> /dev/null &) + done # shellcheck disable=2181 if [[ $? -eq 0 ]]; then -- cgit v1.2.3-70-g09d2 From ead327cc8efc623968b2a14f8a3846b1d79ae630 Mon Sep 17 00:00:00 2001 From: typebrook Date: Sun, 17 May 2020 22:14:22 +0800 Subject: Refactor gist fetching functions - query gists by user now supports pagnation - print '[num] gists fetched' to tty --- gist | 62 +++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/gist b/gist index a3b54ed..0bd4f63 100755 --- a/gist +++ b/gist @@ -389,9 +389,15 @@ _parse_response() { done } +# Get a single JSON object of gist from response, and update index file +_update_gist() { + local record="$(sed -e '1 s/^/[/; $ s/$/]/' | index=$1 _parse_response)" + [[ -n $record ]] && sed -i'' -Ee "/^$1 / s^.+^$record^" $INDEX +} + # Get latest list of gists from Github API _fetch_gists() { - local route="users/$user/gists" + local route=${route:-users/$user/gists} if [[ $mark == s ]]; then route='gists/starred' fi @@ -403,54 +409,52 @@ _fetch_gists() { # consider if HEADER is not exist _fetch_gists_with_pagnation() { - echo "fetching $user's gists from $GITHUB_API..." - echo - - local fetched_records=$(tmp_file fetched) - _fetch_gists "?per_page=$per_page" >> $fetched_records + _fetch_gists "?per_page=$per_page" >> $1 while true; do local next_page='' [[ -e $HEADER ]] && next_page=$(sed -Ene '/^[lL]ink: / s/.+page=([[:digit:]]+)>; rel=\"next\".+/\1/p' $HEADER) [[ -z $next_page ]] && break - printf "%-4s gists fetched\n" $(( ($next_page -1) * $per_page )) + printf "%-4s gists fetched\n" $(( ($next_page -1) * $per_page )) > /dev/tty - _fetch_gists "?per_page=$per_page&page=$next_page" >> $fetched_records + _fetch_gists "?per_page=$per_page&page=$next_page" >> $1 done || return 1 +} - [[ ! -s $fetched_records ]] && echo 'Not a single valid gist' && return 0 +# Update index file by GITHUB API with pagnation +_update_gists() { + echo "fetching $user's gists from $GITHUB_API..." + echo + + local fetched_records=$(tmp_file fetched) + _fetch_gists_with_pagnation $fetched_records || { echo Something screwed; exit 1; } + [[ ! -s $fetched_records ]] && echo 'Not a single valid gist' && return 0 sed -i'' -Ee "/^$mark/ d" $INDEX + + extra="s0 True https://gist.github.com/b0d2e7e67aa50298fdf8111ae7466b56 #bash,#gist NONE README.md@Markdown,gist@Shell 2 30 typebrook 2019-12-26T06:49:40Z 2020-05-15T13:00:31Z [bash-gist] A bash script for gist management" + [[ $mark == s ]] && echo $extra >> $INDEX + tac <$fetched_records | nl -s' ' \ | while read -r "${INDEX_FORMAT[@]:0:2}" extra; do - local prefix=''; [[ $public == False ]] && prefix=p + local prefix='' + [[ $public == False ]] && prefix=p; [[ $mark == s ]] && prefix=s echo $prefix$index $public $extra done >> $INDEX - hint=$hint _show_list + hint=$hint _show_list [[ $auto_sync != false ]] && (_sync_repos &> /dev/null &) true - #extra="s0 https://gist.github.com/b0d2e7e67aa50298fdf8111ae7466b56 #bash,#gist NONE README.md@Markdown,gist@Shell 2 30 typebrook 2019-12-26T06:49:40Z 2020-05-15T13:00:31Z [bash-gist] A bash script for gist management" - #result=$(printf "${extra:+$extra\n}$result") -} - -# Get a single JSON object of gist from response, and update index file -_update_gist() { - local record="$(sed -e '1 s/^/[/; $ s/$/]/' | index=$1 _parse_response)" - [[ -n $record ]] && sed -i'' -Ee "/^$1 / s^.+^$record^" $INDEX } # Fetch gists for a given user -# TODO pagnation for more than 100 gists _query_user() { - local route="users/$1/gists" - result="$(http_method GET $GITHUB_API/$route?per_page=100 | _parse_response)" - [[ -z $result ]] && echo "Failed to query $1's gists" && return 1 - - echo "$result" \ - | while read -r "${INDEX_FORMAT[@]}"; do + local fetched_records=$(tmp_file fetched) + route=users/$1/gists _fetch_gists_with_pagnation $fetched_records + cat $fetched_records \ + | while read -r ${INDEX_FORMAT[@]#index}; do echo "$url $author $file_num $comment_num $description" | cut -c -"$(tput cols)" - done + done || { echo "Failed to query $1's gists"; exit 1; } } # Return the unique code for current commit, to compare repo status and the result of 'gist fetch' @@ -838,7 +842,7 @@ _access_last_index() { } _apply_config "$@" || exit 1 -if [[ $init ]]; then _fetch_gists_with_pagnation; exit 0; fi +if [[ $init ]]; then _update_gists; exit 0; fi case "$1" in "") _show_list ;; @@ -848,7 +852,7 @@ case "$1" in mark=.; _show_list ;; fetch | f) [[ $2 =~ ^(s|star)$ ]] && mark=s || mark=[^s] - _fetch_gists_with_pagnation ;; + _update_gists ;; new | n) shift _create_gist "$@" ;; -- cgit v1.2.3-70-g09d2