diff options
| author | typebrook <typebrook@gmail.com> | 2020-01-31 11:18:57 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-01-31 11:18:57 +0800 |
| commit | 2a8eb396c26ac682315ccfcbd9fe79ff39247b8c (patch) | |
| tree | 143df5908fd4c9725d195dc167803f4631361d5b /scripts | |
| parent | c759dba5f8c5ff60f75343ca45636fa07659fcff (diff) | |
update
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/gist | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/scripts/gist b/scripts/gist index e6b091c..57ef6ec 100755 --- a/scripts/gist +++ b/scripts/gist | |||
| @@ -138,10 +138,9 @@ starred=$folder/starred | |||
| 138 | # TODO a way to show files | 138 | # TODO a way to show files |
| 139 | # TODO show git status outdated | 139 | # TODO show git status outdated |
| 140 | _show_list() { | 140 | _show_list() { |
| 141 | # FIXME how about starred file | ||
| 142 | if [[ ! -e "$1" ]]; then | 141 | if [[ ! -e "$1" ]]; then |
| 143 | echo 'No local file found for last update, please run command:' | 142 | echo 'No local file found for last update, please run command:' |
| 144 | echo " gist update" | 143 | echo " gist update $([[ $1 == $starred ]] && echo 'star')" |
| 145 | return 0 | 144 | return 0 |
| 146 | fi | 145 | fi |
| 147 | cat $1 \ | 146 | cat $1 \ |
| @@ -150,14 +149,13 @@ _show_list() { | |||
| 150 | local occupy=0 | 149 | local occupy=0 |
| 151 | 150 | ||
| 152 | # if repo is not yet cloned, show green message "Not cloned yet" | 151 | # if repo is not yet cloned, show green message "Not cloned yet" |
| 153 | [[ ! -d $repo ]] && extra="\e[32m[Not cloned yet]\e[0m" && occupy=17 | 152 | [[ ! -d $repo ]] && extra="\e[32m[Not cloned yet]\e[0m" && occupy=16 |
| 154 | |||
| 155 | # if there are some changes in git index or working directory, show blue message "working" | 153 | # if there are some changes in git index or working directory, show blue message "working" |
| 156 | [[ -n $(cd $repo && git status --short) ]] 2>/dev/null && extra="\e[36m[working]\e[0m" && occupy=10 | 154 | [[ -n $(cd $repo && git status --short) ]] 2>/dev/null && extra="\e[36m[working]\e[0m" && occupy=9 |
| 157 | # if there is a commit not yet push, show red message "ahead" | 155 | # if there is a commit not yet push, show red message "ahead" |
| 158 | [[ -n $(cd $repo && git cherry) ]] 2>/dev/null && extra="\e[31m[ahead]\e[0m" && occupy=8 | 156 | [[ -n $(cd $repo && git cherry) ]] 2>/dev/null && extra="\e[31m[ahead]\e[0m" && occupy=7 |
| 159 | 157 | ||
| 160 | echo -e $line_num $link $file_num $extra $(echo $description | cut -c -$(( 60 - $occupy )) ) | 158 | echo -e $line_num $link $file_num $extra $(echo $description | cut -c -$(( 60 -$occupy -1 )) ) |
| 161 | done | 159 | done |
| 162 | } | 160 | } |
| 163 | 161 | ||
| @@ -222,7 +220,7 @@ _sync_repos() { | |||
| 222 | local blob_code_local=$(cd $repo && git ls-tree master | cut -d' ' -f3 | cut -c-7 | sort | paste -sd '-') | 220 | local blob_code_local=$(cd $repo && git ls-tree master | cut -d' ' -f3 | cut -c-7 | sort | paste -sd '-') |
| 223 | cd $repo \ | 221 | cd $repo \ |
| 224 | && [[ $blob_code_local != $blob_code_remote ]] \ | 222 | && [[ $blob_code_local != $blob_code_remote ]] \ |
| 225 | &&[[ $(git rev-parse origin/master) == $(git rev-parse master) ]] \ | 223 | && [[ $(git rev-parse origin/master) == $(git rev-parse master) ]] \ |
| 226 | && git pull | 224 | && git pull |
| 227 | done | 225 | done |
| 228 | echo Everything is fine! | 226 | echo Everything is fine! |