aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xbin/init/sync.sh8
-rwxr-xr-xbin/wakeup.sh2
-rw-r--r--zsh/zshrc8
3 files changed, 12 insertions, 6 deletions
diff --git a/bin/init/sync.sh b/bin/init/sync.sh
index 351bb74..413256a 100755
--- a/bin/init/sync.sh
+++ b/bin/init/sync.sh
@@ -3,7 +3,11 @@
3# If git is working in other process, then don't sync again 3# If git is working in other process, then don't sync again
4pidof git >/dev/null && exit 0 4pidof git >/dev/null && exit 0
5 5
6# my repo 6# Print information about ~/.wakeup
7echo 'latest: ' $(date -d @`stat -c %Y ~/.wakeup` --iso-8601=minutes)
8echo 'wakeup at: ' $(cat ~/.wakeup | xargs -i date -d @{} --iso-8601=minutes)
9
10# Sync a repo
7sync() { 11sync() {
8 cd "$1" || return 12 cd "$1" || return
9 [ -z "$(git remote -v)" ] && return 13 [ -z "$(git remote -v)" ] && return
@@ -13,6 +17,7 @@ sync() {
13 echo "Has trouble when syncing $(pwd)" 17 echo "Has trouble when syncing $(pwd)"
14} 18}
15 19
20# Read file ~/.repos, and sync
16sed /^#/d ~/.repos | while read -r repo; do 21sed /^#/d ~/.repos | while read -r repo; do
17 eval "sync $repo &" 22 eval "sync $repo &"
18done 23done
@@ -28,5 +33,6 @@ done
28 33
29touch ~/.wakeup 34touch ~/.wakeup
30 35
36
31# others repo 37# others repo
32#check_upstream ~/git/tig || echo in `pwd` >/dev/tty & 38#check_upstream ~/git/tig || echo in `pwd` >/dev/tty &
diff --git a/bin/wakeup.sh b/bin/wakeup.sh
index 4ceee6a..083499f 100755
--- a/bin/wakeup.sh
+++ b/bin/wakeup.sh
@@ -1,3 +1,3 @@
1#! /bin/bash 1#! /bin/bash
2 2
3date --iso-8601=minutes >~/.wakeup 3date +%s >~/.wakeup
diff --git a/zsh/zshrc b/zsh/zshrc
index 1e31ecf..74b6b63 100644
--- a/zsh/zshrc
+++ b/zsh/zshrc
@@ -47,9 +47,9 @@ function _get_context() {
47 fi 47 fi
48} 48}
49 49
50function _sync_after_wakeup() { 50function _need_sync_after_wakeup() {
51 latest=$(date -d @`stat -c %Y ~/.wakeup` --iso-8601=minutes) 51 latest=$(date -d @`stat -c %Y ~/.wakeup` +%s)
52 test ! "$latest" = "$(cat ~/.wakeup)" 52 test "$latest" -ge "$(cat ~/.wakeup)"
53} 53}
54 54
55autoload -Uz add-zsh-hook 55autoload -Uz add-zsh-hook
@@ -71,7 +71,7 @@ function precmd() {
71 # Show context and git status of tracking repos at right 71 # Show context and git status of tracking repos at right
72 UNSYNC_REPOS=$(NUM=$($SETTING_DIR/bin/git/check-repos.sh -n); (( $NUM != 0 )) && echo $NUM) 72 UNSYNC_REPOS=$(NUM=$($SETTING_DIR/bin/git/check-repos.sh -n); (( $NUM != 0 )) && echo $NUM)
73 _get_context 73 _get_context
74 NEED_SYNC=$(_sync_after_wakeup || echo S) 74 NEED_SYNC=$(_need_sync_after_wakeup || echo S)
75 RPROMPT="%B%K{blue}%F{yellow}${CONTEXT:+ $CONTEXT }%f%k%K{red}%F{black}${UNSYNC_REPOS}${NEED_SYNC}%f%k%b" 75 RPROMPT="%B%K{blue}%F{yellow}${CONTEXT:+ $CONTEXT }%f%k%K{red}%F{black}${UNSYNC_REPOS}${NEED_SYNC}%f%k%b"
76 76
77 77