aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-01-20 10:42:28 +0800
committertypebrook <typebrook@gmail.com>2020-01-20 10:42:28 +0800
commit1ece646af85fbbf55098e2464055278a23352207 (patch)
tree6a2401f460ee66c209ac9c59bb9745073f288f19 /scripts
parent0285db18316e21ea4ef15813ef69b25ca0c20b86 (diff)
update
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gist35
1 files changed, 18 insertions, 17 deletions
diff --git a/scripts/gist b/scripts/gist
index aafee26..3d355c5 100755
--- a/scripts/gist
+++ b/scripts/gist
@@ -162,8 +162,11 @@ _goto_gist() {
162 162
163# TODO delete multiple gists at the same time 163# TODO delete multiple gists at the same time
164_delete_gist() { 164_delete_gist() {
165 _gist_id $1 165 for i in "$@"; do
166 curl -X DELETE -s -H "$auth_header" $github_api/gists/$GIST_ID && \ 166 _gist_id "$i"
167 curl -X DELETE -s -H "$auth_header" $github_api/gists/$GIST_ID && \
168 echo "$i" deleted
169 done
167 _update 170 _update
168} 171}
169 172
@@ -191,22 +194,20 @@ _new_file() {
191 tmp_file=$(mktemp) 194 tmp_file=$(mktemp)
192 cat > $tmp_file 195 cat > $tmp_file
193 echo 196 echo
194 filename=$1 197 [[ -z "$1" ]] && echo -n 'Type file name: ' > /dev/tty && read filename
195 [[ -z $filename ]] && echo -n 'Type file name: ' > /dev/tty && read filename
196 mv $tmp_file /tmp/$filename 198 mv $tmp_file /tmp/$filename
197 echo /tmp/$filename 199 echo /tmp/$filename
198} 200}
199 201
200_set_gist() { 202_set_gist() {
201 for i in "$@"; do 203 while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do case $1 in
202 case "$i" in 204 -d)
203 -d) 205 description="$2"
204 description="$2" 206 shift; shift;;
205 shift; shift;; 207 -f)
206 -f) 208 filename="$2"
207 filename="$2" 209 shift; shift;;
208 shift; shift;; 210 esac
209 esac
210 done 211 done
211 files=$@ 212 files=$@
212} 213}
@@ -215,9 +216,8 @@ _set_gist() {
215# FIXME error handling if gist is not created 216# FIXME error handling if gist is not created
216_create_gist() { 217_create_gist() {
217 _set_gist "$@" 218 _set_gist "$@"
218 219 [[ -z $files ]] && files=$(_new_file $filename)
219 [[ -z "$files" ]] && files=$(_new_file $filename) 220 [[ -z $description ]] && echo -n 'Description: ' && read description
220 [[ -z $description ]] && echo -n 'Description: ' && read description
221 221
222 for file in $files; do 222 for file in $files; do
223 FILE=$(basename $file) 223 FILE=$(basename $file)
@@ -269,7 +269,8 @@ case "$1" in
269 detail | d) 269 detail | d)
270 _show_detail "$2" ;; 270 _show_detail "$2" ;;
271 delete | D) 271 delete | D)
272 _delete_gist "$2" ;; 272 shift
273 _delete_gist "$@" ;;
273 clean | C) 274 clean | C)
274 _clean_repos ;; 275 _clean_repos ;;
275 help | h) 276 help | h)