diff options
Diffstat (limited to 'scripts/gist')
| -rwxr-xr-x | scripts/gist | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/scripts/gist b/scripts/gist index b96998b..f941894 100755 --- a/scripts/gist +++ b/scripts/gist | |||
| @@ -46,6 +46,7 @@ CONFIG=~/.config/gist.conf; mkdir -p ~/.config | |||
| 46 | folder=~/gist && mkdir -p $folder | 46 | folder=~/gist && mkdir -p $folder |
| 47 | action="${EDITOR:-vi} ." | 47 | action="${EDITOR:-vi} ." |
| 48 | auto_sync=true # automatically clone the gist repo | 48 | auto_sync=true # automatically clone the gist repo |
| 49 | [[ -z $hint ]] && hint=true # default to show hint with list of gist | ||
| 49 | 50 | ||
| 50 | # Shell configuration | 51 | # Shell configuration |
| 51 | set -o pipefail | 52 | set -o pipefail |
| @@ -223,7 +224,7 @@ _apply_config() { | |||
| 223 | 224 | ||
| 224 | _check_repo_status() { | 225 | _check_repo_status() { |
| 225 | if [[ ! -d $1 ]]; then | 226 | if [[ ! -d $1 ]]; then |
| 226 | if $auto_sync; then | 227 | if [[ $auto_sync ]]; then |
| 227 | echo "\e[32m[cloning]\e[0m"; | 228 | echo "\e[32m[cloning]\e[0m"; |
| 228 | else | 229 | else |
| 229 | echo "\e[32m[Not cloned yet]\e[0m"; | 230 | echo "\e[32m[Not cloned yet]\e[0m"; |
| @@ -260,7 +261,7 @@ _show_list() { | |||
| 260 | | cut -c -$(tput cols) | 261 | | cut -c -$(tput cols) |
| 261 | done | 262 | done |
| 262 | 263 | ||
| 263 | $hint && echo -e '\nrun "gist fetch" to update gists or "gist help" for more details' > /dev/tty \ | 264 | [[ $hint == 'true' ]] && echo -e '\nrun "gist fetch" to update gists or "gist help" for more details' > /dev/tty \ |
| 264 | || return 0 | 265 | || return 0 |
| 265 | } | 266 | } |
| 266 | 267 | ||
| @@ -328,9 +329,9 @@ _fetch_gists() { | |||
| 328 | [[ -z $result ]] && echo Failed to update gists && return 1 | 329 | [[ -z $result ]] && echo Failed to update gists && return 1 |
| 329 | 330 | ||
| 330 | sed -i'' -e "$filter" $INDEX && echo "$result" >> $INDEX | 331 | sed -i'' -e "$filter" $INDEX && echo "$result" >> $INDEX |
| 331 | mark=$mark hint=true _show_list | 332 | mark=$mark _show_list |
| 332 | 333 | ||
| 333 | $auto_sync && (_sync_repos $1 > /dev/null 2>&1 &) | 334 | [[ $auto_sync == 'true' ]] && (_sync_repos $1 > /dev/null 2>&1 &) |
| 334 | } | 335 | } |
| 335 | 336 | ||
| 336 | _query_user() { | 337 | _query_user() { |
| @@ -551,12 +552,11 @@ usage() { | |||
| 551 | _apply_config "$@" || exit 1 | 552 | _apply_config "$@" || exit 1 |
| 552 | getConfiguredClient || exit 1 | 553 | getConfiguredClient || exit 1 |
| 553 | if [[ $init ]]; then _fetch_gists; exit 0; fi | 554 | if [[ $init ]]; then _fetch_gists; exit 0; fi |
| 554 | [[ -z $hint ]] && hint=true | ||
| 555 | case "$1" in | 555 | case "$1" in |
| 556 | "") | 556 | "") |
| 557 | hint=$hint _show_list ;; | 557 | _show_list ;; |
| 558 | star | s) | 558 | star | s) |
| 559 | hint=$hint mark=s _show_list ;; | 559 | mark=s _show_list ;; |
| 560 | fetch | f) | 560 | fetch | f) |
| 561 | _fetch_gists "$2" ;; | 561 | _fetch_gists "$2" ;; |
| 562 | new | n) | 562 | new | n) |