summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-01-31 11:37:23 +0800
committertypebrook <typebrook@gmail.com>2020-01-31 11:37:23 +0800
commit3370ee794c2d172a1647fe57caea2669b567c046 (patch)
treec868b33dc843b38c5cb09f660353fefb102043fb
parentaeb9e4f968c38117f10d9997e6dff5e5d6e75411 (diff)
update
-rwxr-xr-xscripts/gist16
1 files changed, 8 insertions, 8 deletions
diff --git a/scripts/gist b/scripts/gist
index 34d1351..bd48566 100755
--- a/scripts/gist
+++ b/scripts/gist
@@ -63,7 +63,7 @@ set -eo pipefail
63[ "$TRACE" ] && set -x 63[ "$TRACE" ] && set -x
64 64
65GITHUB_API=https://api.github.com 65GITHUB_API=https://api.github.com
66config=~/.config/gistrc 66CONFIG=~/.config/gistrc
67mkdir -p ~/.config && umask 0077 67mkdir -p ~/.config && umask 0077
68 68
69_config_cases() { 69_config_cases() {
@@ -82,12 +82,12 @@ _config_cases() {
82} 82}
83 83
84_configure() { 84_configure() {
85 [[ -z "$@" ]] && (${EDITOR:-vi} $config) && return 0 85 [[ -z "$@" ]] && (${EDITOR:-vi} $CONFIG) && return 0
86 target=$(_config_cases "$@") 86 target=$(_config_cases "$@")
87 87
88 touch $config 88 touch $CONFIG
89 [[ "$target" =~ [^=]$ ]] && sed -i "/^$1=/ d" $config && echo $target >> $config 89 [[ "$target" =~ [^=]$ ]] && sed -i "/^$1=/ d" $CONFIG && echo $target >> $CONFIG
90 cat $config 90 cat $CONFIG
91} 91}
92 92
93_ask_username() { 93_ask_username() {
@@ -113,8 +113,8 @@ _ask_token() {
113} 113}
114 114
115_apply_config() { 115_apply_config() {
116 source $config 116 source $CONFIG
117 if [[ ! -e $config ]] || [[ -z $user ]]; then 117 if [[ ! -e $CONFIG ]] || [[ -z $user ]]; then
118 echo 'Hi fellow! To access your gists, I need your Github username, also a personal token with scope which allows "gist"!' 118 echo 'Hi fellow! To access your gists, I need your Github username, also a personal token with scope which allows "gist"!'
119 _ask_username 119 _ask_username
120 _ask_token 120 _ask_token
@@ -122,7 +122,7 @@ _apply_config() {
122 _ask_token 122 _ask_token
123 fi 123 fi
124 124
125 source $config 125 source $CONFIG
126} 126}
127 127
128_apply_config "$@" 128_apply_config "$@"