From 818e71003eb96d8c452d5e5227347770481339ac Mon Sep 17 00:00:00 2001 From: typebrook Date: Fri, 17 Jan 2020 14:12:23 +0800 Subject: update --- scripts/gist | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'scripts/gist') diff --git a/scripts/gist b/scripts/gist index 3262a76..11fda56 100755 --- a/scripts/gist +++ b/scripts/gist @@ -128,27 +128,26 @@ _sync_repos() { _gist_id() { GIST_ID=$(cat $index $starred | sed -n "/^$1 / p" | cut -d' ' -f2 | sed -E 's#.*/##') if [[ -z $GIST_ID ]]; then - echo Not a valid index: $1 + echo -e "Not a valid index: \e[31m$1\e[0m" echo Use the index number in the first column instead: echo _show_list "$index $starred" - return 1 - else - echo $GIST_ID + exit 1 fi } +# FIXME error handling _goto_gist() { - GIST_ID=$(_gist_id $1 || return 0) + _gist_id $1 echo This gist is at $folder/$GIST_ID - echo -e "You can use the following command to jump to this directory: \n" - echo -e " \e[31m. gist $1\e[0m" + echo -e "You can run the following command to jump to this directory: \n" + echo -e " \e[32m. gist $1\e[0m" echo cd $folder/$GIST_ID && ls && tig --all 2> /dev/null } _delete_gist() { - GIST_ID=$(_gist_id $1 || return 0) + _gist_id $1 curl -X DELETE -s -H "$auth_header" $github_api/gists/$GIST_ID && \ _update } @@ -164,7 +163,7 @@ _clean_repos() { # TODO format with simple text _show_detail() { - GIST_ID=$(_gist_id $1 || return 0) + _gist_id $1 curl -s -H "$auth_header" $github_api/gists/$GIST_ID |\ jq '{site: .html_url, description: .description, public: .public, API: .url, created_at: .created_at, updated_at: .updated_at, files: (.files | keys)}' @@ -194,7 +193,7 @@ _create_gist() { # update description of a gist _edit_gist() { - GIST_ID=$(_gist_id $1 || return 0) + _gist_id $1 echo -n 'Type new description: ' read DESC -- cgit v1.2.3-70-g09d2