diff options
| author | typebrook <typebrook@gmail.com> | 2020-03-12 10:17:33 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-03-12 10:17:33 +0800 |
| commit | 81f425f06133c2a2f26176fa946cc3eda614e41b (patch) | |
| tree | 665429689551cd36e02f43bdef89101d774cbe9b | |
| parent | d7f13db9a19e220fb69648846e3639abdfdb5cc2 (diff) | |
update
| -rwxr-xr-x | gist | 7 |
1 files changed, 4 insertions, 3 deletions
| @@ -18,7 +18,7 @@ | |||
| 18 | # edit, e <index_of_gist> Edit a gist's description | 18 | # edit, e <index_of_gist> Edit a gist's description |
| 19 | # delete, D <index_of_gist>... Delete a gist | 19 | # delete, D <index_of_gist>... Delete a gist |
| 20 | # clean, C Clean removed gists in local | 20 | # clean, C Clean removed gists in local |
| 21 | # config, c [token | user | folder | auto_sync | EDITOR | action | protocol [value] ] Do configuration | 21 | # config, c [token | user | folder | auto_sync | EDITOR | action | protocol <value> ] Do configuration |
| 22 | # user, U <user> Get gists from a given Github user | 22 | # user, U <user> Get gists from a given Github user |
| 23 | # grep, g <pattern> Grep gists by a given pattern | 23 | # grep, g <pattern> Grep gists by a given pattern |
| 24 | # push, p <index_of_gist> Push changes by git (well, better to make commit by youself) | 24 | # push, p <index_of_gist> Push changes by git (well, better to make commit by youself) |
| @@ -43,7 +43,6 @@ configuredClient="" | |||
| 43 | GITHUB_API=https://api.github.com | 43 | GITHUB_API=https://api.github.com |
| 44 | CONFIG=~/.config/gist.conf; mkdir -p ~/.config | 44 | CONFIG=~/.config/gist.conf; mkdir -p ~/.config |
| 45 | 45 | ||
| 46 | folder=~/gist && mkdir -p $folder | ||
| 47 | action="${EDITOR:-vi} ." | 46 | action="${EDITOR:-vi} ." |
| 48 | [[ -z $hint ]] && hint=true # default to show hint with list of gist | 47 | [[ -z $hint ]] && hint=true # default to show hint with list of gist |
| 49 | [[ -z $confirm ]] && confirm=true # default to confirm when deleting gists | 48 | [[ -z $confirm ]] && confirm=true # default to confirm when deleting gists |
| @@ -225,6 +224,8 @@ _validate_config(){ | |||
| 225 | # load configuration | 224 | # load configuration |
| 226 | _apply_config() { | 225 | _apply_config() { |
| 227 | _validate_config "$@" || return 1 | 226 | _validate_config "$@" || return 1 |
| 227 | |||
| 228 | [[ -z $folder ]] && folder=~/gist; mkdir -p $folder | ||
| 228 | INDEX=$folder/index; [[ -e $INDEX ]] || touch $INDEX | 229 | INDEX=$folder/index; [[ -e $INDEX ]] || touch $INDEX |
| 229 | } | 230 | } |
| 230 | 231 | ||
| @@ -328,7 +329,7 @@ _fetch_gists() { | |||
| 328 | local route="users/$user/gists" | 329 | local route="users/$user/gists" |
| 329 | local filter='/^[^s]/ d; /^$/ d' | 330 | local filter='/^[^s]/ d; /^$/ d' |
| 330 | if [[ $1 =~ ^(star|s)$ ]];then | 331 | if [[ $1 =~ ^(star|s)$ ]];then |
| 331 | route="gists/starred" | 332 | route='gists/starred' |
| 332 | local mark="s" | 333 | local mark="s" |
| 333 | filter='/^[s]/ d; /^$/ d' | 334 | filter='/^[s]/ d; /^$/ d' |
| 334 | fi | 335 | fi |