From 0285db18316e21ea4ef15813ef69b25ca0c20b86 Mon Sep 17 00:00:00 2001 From: typebrook Date: Sun, 19 Jan 2020 19:20:29 +0800 Subject: update --- scripts/gist | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'scripts/gist') diff --git a/scripts/gist b/scripts/gist index 7f8fad0..aafee26 100755 --- a/scripts/gist +++ b/scripts/gist @@ -103,8 +103,7 @@ _update() { curl -s -H "$auth_header" $github_api/$route |\ _parse_response | nl -s' ' | sed -E "s/^ */$mark/" > $list_file && \ _show_list $list_file - #(_sync_repos $1 > /dev/null 2>&1 &) - _sync_repos $1 + (_sync_repos $1 > /dev/null 2>&1 &) } # TODO check if a user create a very first gist @@ -161,6 +160,7 @@ _goto_gist() { cd $folder/$GIST_ID && ls && tig --all 2> /dev/null } +# TODO delete multiple gists at the same time _delete_gist() { _gist_id $1 curl -X DELETE -s -H "$auth_header" $github_api/gists/$GIST_ID && \ @@ -197,27 +197,27 @@ _new_file() { echo /tmp/$filename } +_set_gist() { + for i in "$@"; do + case "$i" in + -d) + description="$2" + shift; shift;; + -f) + filename="$2" + shift; shift;; + esac + done + files=$@ +} + # create a new gist with files +# FIXME error handling if gist is not created _create_gist() { - for i in "$@" - do - case $i in - -d) - echo $@ - description=$2 - shift; shift - echo desc $description ;; - -f) - echo $@ - filename=$2 - shift; shift - echo filename $filename ;; - esac - done - exit 0 + _set_gist "$@" - files=$@ && [[ -z "$files" ]] && files=$(_new_file $filename) - [[ -z $description ]] && echo -n 'Description: ' && read description + [[ -z "$files" ]] && files=$(_new_file $filename) + [[ -z $description ]] && echo -n 'Description: ' && read description for file in $files; do FILE=$(basename $file) @@ -261,7 +261,7 @@ case "$1" in _update "$2" ;; new | n) shift - _create_gist $@ ;; + _create_gist "$@" ;; edit | e) _edit_gist "$2" ;; sync | S) -- cgit v1.2.3-70-g09d2