aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2019-12-23 13:21:10 +0800
committertypebrook <typebrook@gmail.com>2019-12-23 13:21:10 +0800
commitb747017036f18b3dfc98f363233a53bba4b95143 (patch)
tree4cb6f99a2fa86b659cee01c228c5b69625c86233
parentae8137eb9d5e7323412d561a76f58b556f2dafa7 (diff)
update
-rw-r--r--alias3
-rwxr-xr-xscripts/gist/gist16
2 files changed, 16 insertions, 3 deletions
diff --git a/alias b/alias
index a69307d..f3fe1da 100644
--- a/alias
+++ b/alias
@@ -71,7 +71,7 @@ alias ce='crontab -e'
71# ranger 71# ranger
72alias r='_ranger-cd' 72alias r='_ranger-cd'
73alias ranrc='vim ~/.config/ranger/rc.conf' 73alias ranrc='vim ~/.config/ranger/rc.conf'
74function ranger-cd() { 74_ranger-cd() {
75 tempfile="$(mktemp -t tmp.XXXXXX)" 75 tempfile="$(mktemp -t tmp.XXXXXX)"
76 ranger --choosedir="$tempfile" "${@:-$(pwd)}" 76 ranger --choosedir="$tempfile" "${@:-$(pwd)}"
77 test -f "$tempfile" && 77 test -f "$tempfile" &&
@@ -245,3 +245,4 @@ alias cdand='cd ~/git/sample'
245repo='git@github.com' 245repo='git@github.com'
246hub='https://github.com' 246hub='https://github.com'
247typebrook='git@github.com:typebrook' 247typebrook='git@github.com:typebrook'
248GITHUB_API='https://api.github.com'
diff --git a/scripts/gist/gist b/scripts/gist/gist
index 027db8c..200ed5a 100755
--- a/scripts/gist/gist
+++ b/scripts/gist/gist
@@ -2,7 +2,7 @@
2 2
3github_api_token=$(cat $SETTING_DIR/tokens/github) 3github_api_token=$(cat $SETTING_DIR/tokens/github)
4 4
5function _update(){ 5function _update() {
6 curl -s -H "Authorization: OAuth $github_api_token" https://api.github.com/users/typebrook/gists |\ 6 curl -s -H "Authorization: OAuth $github_api_token" https://api.github.com/users/typebrook/gists |\
7 jq '.[] | "\( .html_url ) \(.files | keys | length) \( .description )"' |\ 7 jq '.[] | "\( .html_url ) \(.files | keys | length) \( .description )"' |\
8 tr -d '"' | tac | nl |\ 8 tr -d '"' | tac | nl |\
@@ -11,12 +11,24 @@ function _update(){
11 done | tee ~/.gist 11 done | tee ~/.gist
12} 12}
13 13
14function _get_gist() {
15 GIST_ID=$(cat ~/.gist | sed -n "$1"p | cut -d' ' -f2 | sed -r 's#.*/([^/]+)$#\1#')
16
17 curl -s -H "Authorization: OAuth $github_api_token" https://api.github.com/gists/$GIST_ID |\
18 jq .files
19}
20
21if [[ $# -eq 0 ]]; then
22 cat ~/.gist
23 exit 0
24fi
25
14case "$1" in 26case "$1" in
15 update | u) 27 update | u)
16 _update 28 _update
17 ;; 29 ;;
18 30
19 *) 31 *)
20 cat ~/.gist 32 _get_gist $1
21 ;; 33 ;;
22esac 34esac