diff options
author | typebrook <typebrook@gmail.com> | 2020-02-05 10:57:04 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2020-02-05 10:57:04 +0800 |
commit | a7a4eeb40cd5780bdcbc36bf9c85e558846aead5 (patch) | |
tree | f30d2fd1193cf0cd87cde51a4c7f5951844b7f12 | |
parent | a2bc06ce83ce314d7acf7c238dc243c3d6816880 (diff) |
update
-rw-r--r-- | alias | 4 | ||||
-rwxr-xr-x | scripts/gist | 8 |
2 files changed, 7 insertions, 5 deletions
@@ -220,7 +220,9 @@ alias m='mutt' | |||
220 | # misc | 220 | # misc |
221 | alias foo='echo bar > foo && echo File foo is created && ls -lh foo' | 221 | alias foo='echo bar > foo && echo File foo is created && ls -lh foo' |
222 | alias bar='echo foo > bar && echo File bar is created && ls -lh bar' | 222 | alias bar='echo foo > bar && echo File bar is created && ls -lh bar' |
223 | alias token="cd $SETTING_DIR/tokens && ls -lh" | 223 | token() { |
224 | cd $SETTING_DIR/tokens && cat $1 | ||
225 | } | ||
224 | alias gr='_grepString' | 226 | alias gr='_grepString' |
225 | _grepString() { | 227 | _grepString() { |
226 | grep -R $1 . | 228 | grep -R $1 . |
diff --git a/scripts/gist b/scripts/gist index 5c62a18..20e8f06 100755 --- a/scripts/gist +++ b/scripts/gist | |||
@@ -97,8 +97,7 @@ _validate_config(){ | |||
97 | echo 'Hi fellow! To access your gists, I need your Github username' | 97 | echo 'Hi fellow! To access your gists, I need your Github username' |
98 | echo "Also a personal token with scope which allows "gist"!'" | 98 | echo "Also a personal token with scope which allows "gist"!'" |
99 | echo | 99 | echo |
100 | _ask_username | 100 | _ask_username && _ask_token && init=true |
101 | _ask_token | ||
102 | elif [[ -z $token && $1 =~ ^(n|new|e|edit|D|delete)$ ]]; then | 101 | elif [[ -z $token && $1 =~ ^(n|new|e|edit|D|delete)$ ]]; then |
103 | if ! (_ask_token); then | 102 | if ! (_ask_token); then |
104 | echo 'To create/edit/delete a gist, a token is needed' | 103 | echo 'To create/edit/delete a gist, a token is needed' |
@@ -180,10 +179,10 @@ _show_list() { | |||
180 | # if there is a commit not yet push, show red message "ahead" | 179 | # if there is a commit not yet push, show red message "ahead" |
181 | [[ -n $(cd $repo && git cherry) ]] 2>/dev/null && extra="\e[31m[ahead]\e[0m" && occupy=7 | 180 | [[ -n $(cd $repo && git cherry) ]] 2>/dev/null && extra="\e[31m[ahead]\e[0m" && occupy=7 |
182 | 181 | ||
183 | echo -e "$(printf "% 3s" $index) $link $name $file_num $extra $(echo $description | cut -c -$(( 60 -$occupy -1 )) )" | 182 | echo -e "$(printf "% 3s" $index)" $link $name $file_num $extra $(echo $description | cut -c -$(( 60 -$occupy -1 )) ) |
184 | done < $INDEX \ | 183 | done < $INDEX \ |
185 | | sed "$filter" | 184 | | sed "$filter" |
186 | echo -e '\nrun "gist help" for more details' > /dev/null | 185 | echo -e '\nrun "gist help" for more details' > /dev/tty |
187 | } | 186 | } |
188 | 187 | ||
189 | # parse JSON from STDIN with string of commands | 188 | # parse JSON from STDIN with string of commands |
@@ -449,6 +448,7 @@ usage() { | |||
449 | } | 448 | } |
450 | 449 | ||
451 | getConfiguredClient | 450 | getConfiguredClient |
451 | if [[ $init ]]; then _update; exit 0; fi | ||
452 | case "$1" in | 452 | case "$1" in |
453 | "") | 453 | "") |
454 | _show_list ;; | 454 | _show_list ;; |