From 63ba313be4a696255978f7b93b196391a1a9180b Mon Sep 17 00:00:00 2001 From: typebrook Date: Mon, 23 Dec 2019 10:46:23 +0800 Subject: update --- scripts/gist/gist | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'scripts/gist') diff --git a/scripts/gist/gist b/scripts/gist/gist index d3aa518..027db8c 100755 --- a/scripts/gist/gist +++ b/scripts/gist/gist @@ -2,9 +2,21 @@ github_api_token=$(cat $SETTING_DIR/tokens/github) -curl -s -H "Authorization: OAuth $github_api_token" https://api.github.com/users/typebrook/gists |\ -jq '.[] | "\( .html_url ) \(.files | keys | length) \( .description )"' |\ -tr -d '"' | tac | nl |\ -while read line_num link file_num description; do - echo $line_num $link $file_num $(echo $description | cut -c -70) -done | tee ~/.gist +function _update(){ + curl -s -H "Authorization: OAuth $github_api_token" https://api.github.com/users/typebrook/gists |\ + jq '.[] | "\( .html_url ) \(.files | keys | length) \( .description )"' |\ + tr -d '"' | tac | nl |\ + while read line_num link file_num description; do + echo $line_num $link $file_num $(echo $description | cut -c -70) + done | tee ~/.gist +} + +case "$1" in + update | u) + _update + ;; + + *) + cat ~/.gist + ;; +esac -- cgit v1.2.3-70-g09d2