diff options
| author | typebrook <typebrook@gmail.com> | 2020-01-17 10:00:57 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-01-17 10:00:57 +0800 |
| commit | 7c39ace1b87baea67f7fc249bb390c873e95332e (patch) | |
| tree | bd55f92e0257cd261beb8ae9a64986ae83206fe6 /scripts | |
| parent | 819751402174719e5535f4c9c11bc1ee16498362 (diff) | |
update
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/gist | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/scripts/gist b/scripts/gist index 15d7003..9457474 100755 --- a/scripts/gist +++ b/scripts/gist | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | # gist [sync | s] | 21 | # gist [sync | s] |
| 22 | # | 22 | # |
| 23 | # * Go to local gist repo | 23 | # * Go to local gist repo |
| 24 | # gist <number_of_gist_in_list> | 24 | # . gist <number_of_gist_in_list> |
| 25 | # | 25 | # |
| 26 | # * create a new gist with a file and description | 26 | # * create a new gist with a file and description |
| 27 | # gist [create | c] <filename> "<description>" | 27 | # gist [create | c] <filename> "<description>" |
| @@ -44,6 +44,8 @@ | |||
| 44 | # define your environmemnts here | 44 | # define your environmemnts here |
| 45 | # TODO support auth prompt | 45 | # TODO support auth prompt |
| 46 | # TODO add starred repos | 46 | # TODO add starred repos |
| 47 | # TODO error handling | ||
| 48 | # completion | ||
| 47 | #------------------- | 49 | #------------------- |
| 48 | github_api_token=$(cat $SETTING_DIR/tokens/github) | 50 | github_api_token=$(cat $SETTING_DIR/tokens/github) |
| 49 | user=typebrook | 51 | user=typebrook |
| @@ -65,9 +67,10 @@ _show_list() { | |||
| 65 | cat $index |\ | 67 | cat $index |\ |
| 66 | while read line_num link file_url_array file_num extra description; do | 68 | while read line_num link file_url_array file_num extra description; do |
| 67 | repo=$folder/$(echo $link | sed 's#.*/##') | 69 | repo=$folder/$(echo $link | sed 's#.*/##') |
| 70 | |||
| 68 | # if repo is not yet cloned, show green message "Sync Now" | 71 | # if repo is not yet cloned, show green message "Sync Now" |
| 69 | cd $repo 2>/dev/null || extra="\e[32m[Sync Now]\e[0m" | 72 | cd $repo 2>/dev/null || extra="\e[32m[Sync Now]\e[0m" |
| 70 | # if there is something need to commit, show blue message "working" | 73 | # if there are some changes in git index or working directory, show blue message "working" |
| 71 | [[ -n $(git status --short) ]] 2>/dev/null && extra="\e[36m[working]\e[0m" | 74 | [[ -n $(git status --short) ]] 2>/dev/null && extra="\e[36m[working]\e[0m" |
| 72 | # if there is a commit not yet push, show red message "ahead" | 75 | # if there is a commit not yet push, show red message "ahead" |
| 73 | [[ -n $(git cherry) ]] 2>/dev/null && extra="\e[31m[ahead]\e[0m" | 76 | [[ -n $(git cherry) ]] 2>/dev/null && extra="\e[31m[ahead]\e[0m" |
| @@ -90,6 +93,9 @@ _update() { | |||
| 90 | (_sync_repos > /dev/null 2>&1 &) | 93 | (_sync_repos > /dev/null 2>&1 &) |
| 91 | } | 94 | } |
| 92 | 95 | ||
| 96 | _starred() { | ||
| 97 | } | ||
| 98 | |||
| 93 | _sync_repos() { | 99 | _sync_repos() { |
| 94 | # clone repos which are not in the local | 100 | # clone repos which are not in the local |
| 95 | comm -13 <(find $folder -maxdepth 1 -type d | sed '1d; s#.*/##' | sort) \ | 101 | comm -13 <(find $folder -maxdepth 1 -type d | sed '1d; s#.*/##' | sort) \ |