summaryrefslogtreecommitdiffhomepage
path: root/scripts/gist
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2019-12-24 12:16:32 +0800
committertypebrook <typebrook@gmail.com>2019-12-24 12:16:32 +0800
commit6fd7094002770d43d34c289096d2164f98ef8846 (patch)
tree362f71be0c7b8efdfa6e7b10a4c4d588bf65e3e5 /scripts/gist
parent82d194a2b7461f1c6d924721d29cdb36d06d4567 (diff)
update
Diffstat (limited to 'scripts/gist')
-rwxr-xr-xscripts/gist/gist14
1 files changed, 9 insertions, 5 deletions
diff --git a/scripts/gist/gist b/scripts/gist/gist
index e739b2d..dfe7a50 100755
--- a/scripts/gist/gist
+++ b/scripts/gist/gist
@@ -1,14 +1,17 @@
1#!/bin/bash 1#!/bin/bash
2 2
3github_api_token=$(cat $SETTING_DIR/tokens/github) 3github_api_token=$(cat $SETTING_DIR/tokens/github)
4 4user=typebrook
5folder=~/git/gist 5folder=~/git/gist
6
6mkdir -p $folder 7mkdir -p $folder
7index=$folder/index 8index=$folder/index
8 9
10custom_action='tig --all'
11
9function _update() { 12function _update() {
10 # get the list of gists 13 # get the list of gists
11 curl -s -H "Authorization: OAuth $github_api_token" https://api.github.com/users/typebrook/gists |\ 14 curl -s -H "Authorization: OAuth $github_api_token" https://api.github.com/users/$user/gists |\
12 jq '.[] | "\( .html_url ) \(.files | keys | length) \( .description )"' |\ 15 jq '.[] | "\( .html_url ) \(.files | keys | length) \( .description )"' |\
13 tr -d '"' | tac | nl |\ 16 tr -d '"' | tac | nl |\
14 while read line_num link file_num description; do 17 while read line_num link file_num description; do
@@ -21,9 +24,10 @@ function _update() {
21 xargs -I{} git clone git@github.com:{}.git $folder/{} 24 xargs -I{} git clone git@github.com:{}.git $folder/{}
22} 25}
23 26
24function _get_gist() { 27function _go_to_gist() {
25 GIST_ID=$(cat $index | sed -n "$1"p | cut -d' ' -f2 | sed -r 's#.*/##') 28 GIST_ID=$(cat $index | sed -n "$1"p | cut -d' ' -f2 | sed -r 's#.*/##')
26 cd $folder/$GIST_ID && tig --all 29 cd $folder/$GIST_ID
30 eval $custom_action
27} 31}
28 32
29if [[ $# -eq 0 ]]; then 33if [[ $# -eq 0 ]]; then
@@ -37,6 +41,6 @@ case "$1" in
37 ;; 41 ;;
38 42
39 *) 43 *)
40 _get_gist $1 44 _go_to_gist $1
41 ;; 45 ;;
42esac 46esac