aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/gist
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-01-17 14:12:23 +0800
committertypebrook <typebrook@gmail.com>2020-01-17 14:12:23 +0800
commit818e71003eb96d8c452d5e5227347770481339ac (patch)
treeb0e9239632e0ade5828bef19bd5af7b08b0a82b0 /scripts/gist
parentfa4547ef64a495ba145584fa96ed2889c66b6f16 (diff)
update
Diffstat (limited to 'scripts/gist')
-rwxr-xr-xscripts/gist19
1 files changed, 9 insertions, 10 deletions
diff --git a/scripts/gist b/scripts/gist
index 3262a76..11fda56 100755
--- a/scripts/gist
+++ b/scripts/gist
@@ -128,27 +128,26 @@ _sync_repos() {
128_gist_id() { 128_gist_id() {
129 GIST_ID=$(cat $index $starred | sed -n "/^$1 / p" | cut -d' ' -f2 | sed -E 's#.*/##') 129 GIST_ID=$(cat $index $starred | sed -n "/^$1 / p" | cut -d' ' -f2 | sed -E 's#.*/##')
130 if [[ -z $GIST_ID ]]; then 130 if [[ -z $GIST_ID ]]; then
131 echo Not a valid index: $1 131 echo -e "Not a valid index: \e[31m$1\e[0m"
132 echo Use the index number in the first column instead: 132 echo Use the index number in the first column instead:
133 echo 133 echo
134 _show_list "$index $starred" 134 _show_list "$index $starred"
135 return 1 135 exit 1
136 else
137 echo $GIST_ID
138 fi 136 fi
139} 137}
140 138
139# FIXME error handling
141_goto_gist() { 140_goto_gist() {
142 GIST_ID=$(_gist_id $1 || return 0) 141 _gist_id $1
143 echo This gist is at $folder/$GIST_ID 142 echo This gist is at $folder/$GIST_ID
144 echo -e "You can use the following command to jump to this directory: \n" 143 echo -e "You can run the following command to jump to this directory: \n"
145 echo -e " \e[31m. gist $1\e[0m" 144 echo -e " \e[32m. gist $1\e[0m"
146 echo 145 echo
147 cd $folder/$GIST_ID && ls && tig --all 2> /dev/null 146 cd $folder/$GIST_ID && ls && tig --all 2> /dev/null
148} 147}
149 148
150_delete_gist() { 149_delete_gist() {
151 GIST_ID=$(_gist_id $1 || return 0) 150 _gist_id $1
152 curl -X DELETE -s -H "$auth_header" $github_api/gists/$GIST_ID && \ 151 curl -X DELETE -s -H "$auth_header" $github_api/gists/$GIST_ID && \
153 _update 152 _update
154} 153}
@@ -164,7 +163,7 @@ _clean_repos() {
164 163
165# TODO format with simple text 164# TODO format with simple text
166_show_detail() { 165_show_detail() {
167 GIST_ID=$(_gist_id $1 || return 0) 166 _gist_id $1
168 curl -s -H "$auth_header" $github_api/gists/$GIST_ID |\ 167 curl -s -H "$auth_header" $github_api/gists/$GIST_ID |\
169 jq '{site: .html_url, description: .description, public: .public, API: .url, created_at: .created_at, updated_at: .updated_at, files: (.files | keys)}' 168 jq '{site: .html_url, description: .description, public: .public, API: .url, created_at: .created_at, updated_at: .updated_at, files: (.files | keys)}'
170 169
@@ -194,7 +193,7 @@ _create_gist() {
194 193
195# update description of a gist 194# update description of a gist
196_edit_gist() { 195_edit_gist() {
197 GIST_ID=$(_gist_id $1 || return 0) 196 _gist_id $1
198 197
199 echo -n 'Type new description: ' 198 echo -n 'Type new description: '
200 read DESC 199 read DESC