summaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-01-29 00:55:01 +0800
committertypebrook <typebrook@gmail.com>2020-01-29 00:55:01 +0800
commita7638108082c68ef5ed7c6370d7403937780e343 (patch)
tree5f4a7eed86fce6ed2496b006d0f45e73e01d59a6 /scripts
parentfa1c733a1de04fcf7f261262e209812705c2f645 (diff)
update
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gist13
1 files changed, 5 insertions, 8 deletions
diff --git a/scripts/gist b/scripts/gist
index a54d381..09d67c0 100755
--- a/scripts/gist
+++ b/scripts/gist
@@ -250,6 +250,7 @@ _show_detail() {
250 | jq '.[] | {user: .user.login, created_at: .created_at, updated_at: .updated_at, body: .body}' 250 | jq '.[] | {user: .user.login, created_at: .created_at, updated_at: .updated_at, body: .body}'
251} 251}
252 252
253# FIXME put file before parameters
253_set_gist() { 254_set_gist() {
254 while [[ "$1" =~ ^- && "$1" != "--" ]]; do case $1 in 255 while [[ "$1" =~ ^- && "$1" != "--" ]]; do case $1 in
255 -d | --desc) 256 -d | --desc)
@@ -283,14 +284,10 @@ _create_gist() {
283 [[ -z "$description" ]] && read -p 'Type description: ' description < /dev/tty 284 [[ -z "$description" ]] && read -p 'Type description: ' description < /dev/tty
284 285
285 for file in $files; do 286 for file in $files; do
286 FILE=$(basename $file) 287 filename=$(basename $file)
287 jq --arg FILE "$FILE" '. as $content | { ($FILE): {content: $content} }' -Rs $file 288 echo "\"$filename\": {\"content\": \"$(sed '$ !s/$/\\n/' $file)\"},"
288 done \ 289 done | tr -d '\n' | sed 's/^/{/; s/,$/}/' \
289 | jq --slurp --arg DESC "$description" '{ 290 | echo "{ \"public\": true, \"files\": $(cat -), \"description\": \"$description\"}" \
290 public: true,
291 files: add,
292 description: ($DESC)
293 }' \
294 | curl -s -H "$auth_header" --data @- $github_api/gists \ 291 | curl -s -H "$auth_header" --data @- $github_api/gists \
295 | sed '1 s/^/[/; $ s/$/]/' \ 292 | sed '1 s/^/[/; $ s/$/]/' \
296 | _parse_response \ 293 | _parse_response \