aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/gist
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2019-12-24 17:05:56 +0800
committertypebrook <typebrook@gmail.com>2019-12-24 17:05:56 +0800
commit823d8c6199c418101fdf3f2b58bd1fb3b13eb349 (patch)
tree32b884fcd9a318253f42128e8d96e16ece33809e /scripts/gist
parentd6be8f8ec764229583f2e99fb36f334435453419 (diff)
update
Diffstat (limited to 'scripts/gist')
-rwxr-xr-xscripts/gist15
1 files changed, 3 insertions, 12 deletions
diff --git a/scripts/gist b/scripts/gist
index ffc479f..48acd44 100755
--- a/scripts/gist
+++ b/scripts/gist
@@ -41,22 +41,13 @@ _show_detail() {
41 41
42# FIXME cannot upload a file 42# FIXME cannot upload a file
43_create() { 43_create() {
44 jq '. as $file | {public: true, files: {content: $file}, description: "no desc"}' -R -s $1 |\
45 tee /dev/tty |\
44 curl -v -H "Authorization: token $github_api_token" \ 46 curl -v -H "Authorization: token $github_api_token" \
45 --data "$(generate_post_data $1 | tee json)" \ 47 --data @- \
46 https://api.github.com/gists 48 https://api.github.com/gists
47} 49}
48 50
49generate_post_data() {
50cat <<EOF
51{
52 "public": true,
53 "files": { "$1": {"content": "$(cat $1 | sed 's/"/\\\"/g' | tr '\n' ',')"}},
54 "description": $2
55}
56EOF
57}
58
59
60if [[ $# -eq 0 ]]; then 51if [[ $# -eq 0 ]]; then
61 cat $index 52 cat $index
62 exit 0 53 exit 0