diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2023-04-04 09:45:58 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2023-04-04 09:45:58 +0800 |
| commit | 4f0c2fb9e13307de372e05dede958fa3fdad70b1 (patch) | |
| tree | a2a8a31ae3b6dfd82872b8dab913db5ccf496ce0 /zsh | |
| parent | 39ca31f4002297370572e97ad62b675cf1bc205e (diff) | |
Update
Diffstat (limited to 'zsh')
| -rw-r--r-- | zsh/zshrc | 22 |
1 files changed, 14 insertions, 8 deletions
| @@ -38,12 +38,22 @@ zstyle ':completion::complete:*' gain-privileges 1 | |||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | # PS1 with git status at right | 40 | # PS1 with git status at right |
| 41 | _get_context() { | ||
| 42 | CONTEXT_FILE=${CONTEXT_FILE:-~/.task/context} | ||
| 43 | |||
| 44 | LAST_MODIFY_TIME=$(stat -c %y "$CONTEXT_FILE") | ||
| 45 | if [ ! "$MODIFY_TIME" = "$LAST_MODIFY_TIME" ]; then | ||
| 46 | CONTEXT=$(cat "$CONTEXT_FILE") | ||
| 47 | MODIFY_TIME="$LAST_MODIFY_TIME" | ||
| 48 | fi | ||
| 49 | echo $CONTEXT | ||
| 50 | } | ||
| 41 | autoload -Uz add-zsh-hook | 51 | autoload -Uz add-zsh-hook |
| 42 | add-zsh-hook precmd precmd | 52 | add-zsh-hook precmd precmd |
| 43 | function precmd() { | 53 | function precmd() { |
| 44 | RIGHT=$(NUM=$($SETTING_DIR/bin/git/check-repos.sh -n); (( $NUM != 0 )) && echo $NUM) | 54 | RIGHT=$(NUM=$($SETTING_DIR/bin/git/check-repos.sh -n); (( $NUM != 0 )) && echo $NUM) |
| 45 | PROMPT='%B%(?:%F{green}%m%f:%K{red}%F{black}%m%f%k)%f%F{cyan} %c%f%b ' | 55 | PROMPT='%B%(?:%F{green}%m%f:%K{red}%F{black}%m%f%k)%f%F{cyan} %c%f%b ' |
| 46 | RPROMPT="%B%K{red}%F{black}${RIGHT}%f%k%b" | 56 | RPROMPT="%K{blue}%F{yellow}$(_get_context)%f%k %B%K{red}%F{black}${RIGHT}%f%k%b" |
| 47 | [ -n "$PRE_POPULATE" ] && print -z "$PRE_POPULATE" | 57 | [ -n "$PRE_POPULATE" ] && print -z "$PRE_POPULATE" |
| 48 | } | 58 | } |
| 49 | 59 | ||
| @@ -74,7 +84,7 @@ key[PageDown]="${terminfo[knp]}" | |||
| 74 | key[Shift-Tab]="${terminfo[kcbt]}" | 84 | key[Shift-Tab]="${terminfo[kcbt]}" |
| 75 | 85 | ||
| 76 | # setup key accordingly | 86 | # setup key accordingly |
| 77 | bindkey -- '^[[Z' reverse-menu-complete | 87 | bindkey -- ${key[Shift-Tab]} reverse-menu-complete |
| 78 | #bindkey -- "\C-A" beginning-of-line | 88 | #bindkey -- "\C-A" beginning-of-line |
| 79 | #bindkey -- "\C-E" end-of-line | 89 | #bindkey -- "\C-E" end-of-line |
| 80 | #bindkey -- "\C-d" delete-char | 90 | #bindkey -- "\C-d" delete-char |
| @@ -96,13 +106,9 @@ bindkey -- '^[[Z' reverse-menu-complete | |||
| 96 | #bindkey -- "${key[Insert]}" overwrite-mode | 106 | #bindkey -- "${key[Insert]}" overwrite-mode |
| 97 | 107 | ||
| 98 | 108 | ||
| 99 | # Common shell options | ||
| 100 | alias ls='ls --color' | ||
| 101 | alias grep='grep --color' | ||
| 102 | |||
| 103 | |||
| 104 | # Quick jump to parent folders | 109 | # Quick jump to parent folders |
| 105 | source ~/helper/zsh/bd.zsh | 110 | source $SETTING_DIR/zsh/bd.zsh |
| 111 | |||
| 106 | 112 | ||
| 107 | # Load my general settings | 113 | # Load my general settings |
| 108 | source $SETTING_DIR/bin/init/load-settings.sh | 114 | source $SETTING_DIR/bin/init/load-settings.sh |