aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2025-06-09 15:58:25 +0800
committerHsieh Chin Fan <pham@topo.tw>2025-06-09 15:58:25 +0800
commit6a3a0a9af02f2defe0841901565a612fb09e6ffc (patch)
treef00ff46c22763ad993fa61c2cb27a671e8eb20f5
parent05cd00f21905d63bb7fa3afbdecf374667400794 (diff)
Update
-rw-r--r--alias2
-rw-r--r--zsh/zshrc37
2 files changed, 6 insertions, 33 deletions
diff --git a/alias b/alias
index 69d6bb1..fb38d3a 100644
--- a/alias
+++ b/alias
@@ -411,7 +411,7 @@ cdg() {
411alias cdgg='cd $(git rev-parse --show-toplevel)' 411alias cdgg='cd $(git rev-parse --show-toplevel)'
412alias cdgw='cdgg && cd .github/workflows' 412alias cdgw='cdgg && cd .github/workflows'
413alias cdgs='cd $(git submodule status | sed "s/^.//" | cut -d" " -f2)' # cd to first submodule 413alias cdgs='cd $(git submodule status | sed "s/^.//" | cut -d" " -f2)' # cd to first submodule
414alias ch="/home/pham/helper/bin/git/check-repos.sh" 414ch() { list=~/helper/bin/git/check-repos.sh; test -f $list && $list; }
415alias git.check="/home/pham/helper/bin/git/check-repos.sh" 415alias git.check="/home/pham/helper/bin/git/check-repos.sh"
416alias cgit{.,''}rc='sudo vim /etc/cgitrc' 416alias cgit{.,''}rc='sudo vim /etc/cgitrc'
417 417
diff --git a/zsh/zshrc b/zsh/zshrc
index 2d2b005..7380d8e 100644
--- a/zsh/zshrc
+++ b/zsh/zshrc
@@ -36,29 +36,6 @@ _comp_options+=(globdots) # With hidden files
36zstyle ':completion:*' menu select 36zstyle ':completion:*' menu select
37zstyle ':completion::complete:*' gain-privileges 1 37zstyle ':completion::complete:*' gain-privileges 1
38 38
39# Set variable CONTEXT
40function _get_context() {
41 CONTEXT_FILE=${CONTEXT_FILE:-~/.task/context}
42
43 LAST_MODIFY_TIME=$(stat -c %y "$CONTEXT_FILE")
44 if [ ! "$MODIFY_TIME" = "$LAST_MODIFY_TIME" ]; then
45 CONTEXT=$(cat "$CONTEXT_FILE")
46 MODIFY_TIME="$LAST_MODIFY_TIME"
47 fi
48}
49
50function _already_sync_after_wakeup() {
51 WAKEUP="$HOME/.wakeup"
52 [ ! -e "$WAKEUP" ] && return 0
53
54 latest=$(date -d @`stat -c %X "$WAKEUP"` +%s)
55 # If sync time is older than wakeup time (timestamp in file), then return false
56 if [ $latest -gt "$(cat $WAKEUP)" ]; then
57 return 0
58 else
59 return 1
60 fi
61}
62 39
63autoload -Uz add-zsh-hook 40autoload -Uz add-zsh-hook
64autoload -Uz parameter 41autoload -Uz parameter
@@ -75,14 +52,6 @@ function precmd() {
75 fi 52 fi
76 PROMPT="%B%(?:%F{green}%m%f:%K{red}%F{black}%m%f%k)%f%F{cyan} %c%f%b${jobstring} " 53 PROMPT="%B%(?:%F{green}%m%f:%K{red}%F{black}%m%f%k)%f%F{cyan} %c%f%b${jobstring} "
77 54
78 # RIGHT PROMPT
79 # Show context and git status of tracking repos at right
80 UNSYNC_REPOS=$(NUM=$($SETTING_DIR/bin/git/check-repos.sh -n); (( $NUM != 0 )) && echo $NUM)
81 _get_context
82 NEED_SYNC=$(_already_sync_after_wakeup || echo S)
83 RPROMPT="%B%K{blue}%F{yellow}${CONTEXT:+ $CONTEXT }%f%k%K{red}%F{black}${UNSYNC_REPOS}${NEED_SYNC}%f%k%b"
84
85
86 [ -n "$PRE_POPULATE" ] && print -z "$PRE_POPULATE" 55 [ -n "$PRE_POPULATE" ] && print -z "$PRE_POPULATE"
87} 56}
88 57
@@ -159,4 +128,8 @@ case ":$PATH:" in
159esac 128esac
160# pnpm end 129# pnpm end
161 130
162source ~/.profile 131source ~/.profile 2>/dev/null
132
133# Makefile
134zstyle ':completion:*:make:*:targets' call-command true
135zstyle ':completion:*:*:make:*' tag-order 'targets' 2>/dev/null