diff options
author | typebrook <typebrook@gmail.com> | 2020-02-09 17:36:58 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2020-02-09 17:36:58 +0800 |
commit | c1c3c55f875a7c22f404a20e2f61ea9a7ecb602c (patch) | |
tree | 9aaad390e9646d7dd42e8f840a61e74454e85980 /scripts | |
parent | c68b07ab292257be868406a4e486b1bc7fe44292 (diff) |
update
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/gist | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/scripts/gist b/scripts/gist index a67eca6..c2c500f 100755 --- a/scripts/gist +++ b/scripts/gist | |||
@@ -220,7 +220,11 @@ _apply_config() { | |||
220 | 220 | ||
221 | _check_repo_status() { | 221 | _check_repo_status() { |
222 | if [[ ! -d $1 ]]; then | 222 | if [[ ! -d $1 ]]; then |
223 | if [[ $auto_sync ]]; then echo "\e[32m[cloning]\e[0m"; fi | 223 | if $auto_sync; then |
224 | echo "\e[32m[cloning]\e[0m"; | ||
225 | else | ||
226 | echo "\e[32m[Not cloned yet]\e[0m"; | ||
227 | fi | ||
224 | else | 228 | else |
225 | cd $1 | 229 | cd $1 |
226 | if [[ -n $(git status --short) ]] &>/dev/null; then | 230 | if [[ -n $(git status --short) ]] &>/dev/null; then |
@@ -252,7 +256,7 @@ _show_list() { | |||
252 | echo -e "$(printf "% 3s" $index)" $link $name $extra $description \ | 256 | echo -e "$(printf "% 3s" $index)" $link $name $extra $description \ |
253 | | cut -c -$(tput cols) | 257 | | cut -c -$(tput cols) |
254 | done | 258 | done |
255 | echo -e '\nrun "gist fetch" to update gists or "gist help" for more details' > /dev/tty | 259 | $hint && echo -e '\nrun "gist fetch" to update gists or "gist help" for more details' > /dev/tty |
256 | } | 260 | } |
257 | 261 | ||
258 | # TODO support filenames, file contents | 262 | # TODO support filenames, file contents |
@@ -318,9 +322,9 @@ _fetch_gists() { | |||
318 | [[ -z $result ]] && echo Failed to update gists && return 1 | 322 | [[ -z $result ]] && echo Failed to update gists && return 1 |
319 | 323 | ||
320 | sed -i'' -e "$filter" $INDEX && echo "$result" >> $INDEX | 324 | sed -i'' -e "$filter" $INDEX && echo "$result" >> $INDEX |
321 | mark=$mark _show_list | 325 | mark=$mark hint=true _show_list |
322 | 326 | ||
323 | if [[ $auto_sync != 'false' ]]; then (_sync_repos $1 > /dev/null 2>&1 &); fi | 327 | $auto_sync && (_sync_repos $1 > /dev/null 2>&1 &) |
324 | } | 328 | } |
325 | 329 | ||
326 | _query_user() { | 330 | _query_user() { |
@@ -543,9 +547,10 @@ getConfiguredClient || exit 1 | |||
543 | if [[ $init ]]; then _fetch_gists; exit 0; fi | 547 | if [[ $init ]]; then _fetch_gists; exit 0; fi |
544 | case "$1" in | 548 | case "$1" in |
545 | "") | 549 | "") |
550 | [[ -z "$hint" ]] && hint=true | ||
546 | _show_list ;; | 551 | _show_list ;; |
547 | star | s) | 552 | star | s) |
548 | mark=s _show_list ;; | 553 | hint=true mark=s _show_list ;; |
549 | fetch | f) | 554 | fetch | f) |
550 | _fetch_gists "$2" ;; | 555 | _fetch_gists "$2" ;; |
551 | new | n) | 556 | new | n) |