diff options
author | typebrook <typebrook@gmail.com> | 2019-12-23 13:21:10 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2019-12-23 13:21:10 +0800 |
commit | b747017036f18b3dfc98f363233a53bba4b95143 (patch) | |
tree | 4cb6f99a2fa86b659cee01c228c5b69625c86233 | |
parent | ae8137eb9d5e7323412d561a76f58b556f2dafa7 (diff) |
update
-rw-r--r-- | alias | 3 | ||||
-rwxr-xr-x | scripts/gist/gist | 16 |
2 files changed, 16 insertions, 3 deletions
@@ -71,7 +71,7 @@ alias ce='crontab -e' | |||
71 | # ranger | 71 | # ranger |
72 | alias r='_ranger-cd' | 72 | alias r='_ranger-cd' |
73 | alias ranrc='vim ~/.config/ranger/rc.conf' | 73 | alias ranrc='vim ~/.config/ranger/rc.conf' |
74 | function 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' | |||
245 | repo='git@github.com' | 245 | repo='git@github.com' |
246 | hub='https://github.com' | 246 | hub='https://github.com' |
247 | typebrook='git@github.com:typebrook' | 247 | typebrook='git@github.com:typebrook' |
248 | GITHUB_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 | ||
3 | github_api_token=$(cat $SETTING_DIR/tokens/github) | 3 | github_api_token=$(cat $SETTING_DIR/tokens/github) |
4 | 4 | ||
5 | function _update(){ | 5 | function _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 | ||
14 | function _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 | |||
21 | if [[ $# -eq 0 ]]; then | ||
22 | cat ~/.gist | ||
23 | exit 0 | ||
24 | fi | ||
25 | |||
14 | case "$1" in | 26 | case "$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 | ;; |
22 | esac | 34 | esac |