From 2f687bedf81f26eae1f5889b09f87bef9d4e3238 Mon Sep 17 00:00:00 2001 From: typebrook Date: Tue, 24 Dec 2019 16:32:35 +0800 Subject: update --- scripts/gist | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'scripts/gist') diff --git a/scripts/gist b/scripts/gist index 45572a4..879bc3d 100755 --- a/scripts/gist +++ b/scripts/gist @@ -7,7 +7,7 @@ folder=~/git/gist mkdir -p $folder index=$folder/index -function _update() { +_update() { # get the list of gists curl -s -H "Authorization: token $github_api_token" https://api.github.com/users/$user/gists |\ jq '.[] | "\( .html_url ) \(.files | keys | length) \( .description )"' |\ @@ -22,23 +22,34 @@ function _update() { xargs -I{} git clone git@github.com:{}.git $folder/{} } -function _go_to_gist() { +_go_to_gist() { GIST_ID=$(cat $index | sed -n "$1"p | cut -d' ' -f2 | sed -r 's#.*/##') echo this gist is at $folder/$GIST_ID cd $folder/$GIST_ID && tig --all 2> /dev/null } -function _show_detail() { +_show_detail() { GIST_ID=$(cat $index | sed -n "$1"p | cut -d' ' -f2 | sed -r 's#.*/##') curl -s -H "Authorization: token $github_api_token" https://api.github.com/gists/$GIST_ID } -function _create() { +# FIXME cannot upload a file +_create() { curl -v -H "Authorization: token $github_api_token" \ - --data '{"public":true,"files":{"foo.gpx":{"content":"$2"}}}' \ + --data "$(generate_post_data $1 | tee json)" \ https://api.github.com/gists } +generate_post_data() { +cat <