aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/gist
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gist')
-rwxr-xr-xscripts/gist15
1 files changed, 7 insertions, 8 deletions
diff --git a/scripts/gist b/scripts/gist
index 29bb1e1..a67eca6 100755
--- a/scripts/gist
+++ b/scripts/gist
@@ -202,7 +202,7 @@ _validate_config(){
202 echo 'To create/edit/delete a gist, a token is needed' 202 echo 'To create/edit/delete a gist, a token is needed'
203 return 1 203 return 1
204 fi 204 fi
205 elif [[ -z $token && $1 =~ ^(u|update)$ && $2 =~ ^(s|star) ]]; then 205 elif [[ -z $token && $1 =~ ^(f|fetch)$ && $2 =~ ^(s|star) ]]; then
206 if ! (_ask_token); then 206 if ! (_ask_token); then
207 echo 'To get user starred gists, a token is needed' 207 echo 'To get user starred gists, a token is needed'
208 return 1 208 return 1
@@ -239,8 +239,8 @@ _show_list() {
239 echo ' gist update' 239 echo ' gist update'
240 return 0 240 return 0
241 fi 241 fi
242 [[ -z $1 ]] && local filter='/^ *s/ d; /^$/ d' 242 local filter='/^ *s/ d; /^$/ d'
243 [[ $1 == "s" ]] && local filter='/^ *[^ s]/ d; /^$/ d' 243 [[ $mark == "s" ]] && filter='/^ *[^ s]/ d; /^$/ d'
244 244
245 sed -e "$filter" $INDEX \ 245 sed -e "$filter" $INDEX \
246 | while read index link blob_code file_num comment_num author description; do 246 | while read index link blob_code file_num comment_num author description; do
@@ -307,19 +307,18 @@ _fetch_gists() {
307 echo "fetching $user's gists from $GITHUB_API..." 307 echo "fetching $user's gists from $GITHUB_API..."
308 echo 308 echo
309 local route="users/$user/gists" 309 local route="users/$user/gists"
310 local mark=""
311 local filter='/^[^s]/ d; /^$/ d' 310 local filter='/^[^s]/ d; /^$/ d'
312 if [[ "$1" =~ ^(star|s)$ ]];then 311 if [[ "$1" =~ ^(star|s)$ ]];then
313 route="gists/starred" 312 route="gists/starred"
314 mark="s" 313 local mark="s"
315 filter='/^[s]/ d; /^$/ d' 314 filter='/^[s]/ d; /^$/ d'
316 fi 315 fi
317 316
318 result=$(http_method GET $GITHUB_API/$route | _parse_response) 317 result=$(http_method GET $GITHUB_API/$route | mark=$mark _parse_response)
319 [[ -z $result ]] && echo Failed to update gists && return 1 318 [[ -z $result ]] && echo Failed to update gists && return 1
320 319
321 sed -i'' -e "$filter" $INDEX && echo "$result" >> $INDEX 320 sed -i'' -e "$filter" $INDEX && echo "$result" >> $INDEX
322 _show_list $mark 321 mark=$mark _show_list
323 322
324 if [[ $auto_sync != 'false' ]]; then (_sync_repos $1 > /dev/null 2>&1 &); fi 323 if [[ $auto_sync != 'false' ]]; then (_sync_repos $1 > /dev/null 2>&1 &); fi
325} 324}
@@ -546,7 +545,7 @@ case "$1" in
546 "") 545 "")
547 _show_list ;; 546 _show_list ;;
548 star | s) 547 star | s)
549 _show_list s ;; 548 mark=s _show_list ;;
550 fetch | f) 549 fetch | f)
551 _fetch_gists "$2" ;; 550 _fetch_gists "$2" ;;
552 new | n) 551 new | n)