From f282b0c626047f215cca6607ce46696c4d4df021 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Mon, 15 May 2023 17:32:46 +0800 Subject: Update --- bin/init/sync.sh | 2 ++ zsh/zshrc | 16 ++++++++++++++-- 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 fi done +touch ~/.wakeup + # others repo #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() { fi } +function _sync_after_wakeup() { + latest=$(date -d @`stat -c %Y ~/.wakeup` --iso-8601=minutes) + test ! "$latest" = "$(cat ~/.wakeup)" +} + autoload -Uz add-zsh-hook autoload -Uz parameter add-zsh-hook precmd precmd function precmd() { + + # LEFT PROMPT + # jobstring shows how many jobs in current shell jobstring="$#jobstates"; if [ "$jobstring" = 0 ]; then unset jobstring @@ -59,10 +67,14 @@ function precmd() { fi PROMPT="%B%(?:%F{green}%m%f:%K{red}%F{black}%m%f%k)%f%F{cyan} %c%f%b${jobstring} " + # RIGHT PROMPT # Show context and git status of tracking repos at right - RIGHT=$(NUM=$($SETTING_DIR/bin/git/check-repos.sh -n); (( $NUM != 0 )) && echo $NUM) + UNSYNC_REPOS=$(NUM=$($SETTING_DIR/bin/git/check-repos.sh -n); (( $NUM != 0 )) && echo $NUM) _get_context - RPROMPT="%B%K{blue}%F{yellow}${CONTEXT:+ $CONTEXT }%f%k%K{red}%F{black}${RIGHT}%f%k%b" + NEED_SYNC=$(_sync_after_wakeup || echo S) + RPROMPT="%B%K{blue}%F{yellow}${CONTEXT:+ $CONTEXT }%f%k%K{red}%F{black}${UNSYNC_REPOS}${NEED_SYNC}%f%k%b" + + [ -n "$PRE_POPULATE" ] && print -z "$PRE_POPULATE" } -- cgit v1.2.3-70-g09d2