aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xbin/init/sync.sh2
-rw-r--r--zsh/zshrc16
2 files changed, 16 insertions, 2 deletions
diff --git a/bin/init/sync.sh b/bin/init/sync.sh
index 7521918..5a7c435 100755
--- a/bin/init/sync.sh
+++ b/bin/init/sync.sh
@@ -25,5 +25,7 @@ while true; do
25 fi 25 fi
26done 26done
27 27
28touch ~/.wakeup
29
28# others repo 30# others repo
29#check_upstream ~/git/tig || echo in `pwd` >/dev/tty & 31#check_upstream ~/git/tig || echo in `pwd` >/dev/tty &
diff --git a/zsh/zshrc b/zsh/zshrc
index ab08c29..1e31ecf 100644
--- a/zsh/zshrc
+++ b/zsh/zshrc
@@ -47,10 +47,18 @@ function _get_context() {
47 fi 47 fi
48} 48}
49 49
50function _sync_after_wakeup() {
51 latest=$(date -d @`stat -c %Y ~/.wakeup` --iso-8601=minutes)
52 test ! "$latest" = "$(cat ~/.wakeup)"
53}
54
50autoload -Uz add-zsh-hook 55autoload -Uz add-zsh-hook
51autoload -Uz parameter 56autoload -Uz parameter
52add-zsh-hook precmd precmd 57add-zsh-hook precmd precmd
53function precmd() { 58function precmd() {
59
60 # LEFT PROMPT
61 # jobstring shows how many jobs in current shell
54 jobstring="$#jobstates"; 62 jobstring="$#jobstates";
55 if [ "$jobstring" = 0 ]; then 63 if [ "$jobstring" = 0 ]; then
56 unset jobstring 64 unset jobstring
@@ -59,10 +67,14 @@ function precmd() {
59 fi 67 fi
60 PROMPT="%B%(?:%F{green}%m%f:%K{red}%F{black}%m%f%k)%f%F{cyan} %c%f%b${jobstring} " 68 PROMPT="%B%(?:%F{green}%m%f:%K{red}%F{black}%m%f%k)%f%F{cyan} %c%f%b${jobstring} "
61 69
70 # RIGHT PROMPT
62 # Show context and git status of tracking repos at right 71 # Show context and git status of tracking repos at right
63 RIGHT=$(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)
64 _get_context 73 _get_context
65 RPROMPT="%B%K{blue}%F{yellow}${CONTEXT:+ $CONTEXT }%f%k%K{red}%F{black}${RIGHT}%f%k%b" 74 NEED_SYNC=$(_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"
76
77
66 [ -n "$PRE_POPULATE" ] && print -z "$PRE_POPULATE" 78 [ -n "$PRE_POPULATE" ] && print -z "$PRE_POPULATE"
67} 79}
68 80