-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
108 lines (98 loc) · 4.06 KB
/
.zshrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# https://www.reddit.com/r/zsh/comments/qinb6j/httpsgithubcomzdharma_has_suddenly_disappeared_i/
#
# Added by Zinit's installer
#
# How to install: https://github.com/zdharma-continuum/zinit#manual-installation
#
## Copied from:
## https://zhuanlan.zhihu.com/p/98450570
## refers to
## https://github.com/Aloxaf/dotfiles/blob/master/zsh/.config/zsh/zshrc.zsh
# {{{ HISTORY settings. 放在 .zshenv 中不生效,不知在哪里被覆盖了。
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
export HISTFILE=~/.zsh_history
export SAVEHIST=20000 # save history after logout
export HISTSIZE=40000 # set history size
# setopt SHARE_HISTORY
setopt INC_APPEND_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_SPACE
setopt EXTENDED_HISTORY #add timestamp for each entry
# }}}
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit"
skip_global_compinit="1"
source "${ZINIT_HOME}/zinit.git/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
# Turbo-enabled CompDefs
autoload -Uz compinit && compinit
# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
Aloxaf/fzf-tab \
zdharma-continuum/zinit-annex-as-monitor \
zdharma-continuum/zinit-annex-bin-gem-node \
zdharma-continuum/zinit-annex-patch-dl \
zdharma-continuum/zinit-annex-rust \
junegunn/fzf \
b4b4r07/enhancd \
atinit"zicompinit; zicdreplay" \
zdharma-continuum/fast-syntax-highlighting \
atload"_zsh_autosuggest_start" \
zsh-users/zsh-autosuggestions \
blockf atpull'zinit creinstall -q .' \
zsh-users/zsh-completions
# disable sort when completing `git checkout`
zstyle ':completion:*:git-checkout:*' sort false
# set list-colors to enable filename colorizing
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# force zsh not to show completion menu, which allows fzf-tab to capture the unambiguous prefix
zstyle ':completion:*' menu no
# preview directory's content with eza when completing cd
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath'
# 如果是 'm:{a-zA-Z}={A-Za-z}',则 ls/vim 等操作不自动补全。比如某文件只有e f 两个文本文件
# 这里 follow vim 的按键方案,不区分大小写,然而当输入大写字母,则为大小写敏感了
# https://superuser.com/a/1092328 cd case-insensitive matching
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# 限定 ssh 主机补全
zstyle ':completion:*:ssh:*' hosts $(awk '/^Host / {print $2}' ~/.ssh/config)
zstyle ':completion:*:*:ssh:*' tag-order 'hosts'
# switch group using `<` and `>`
zstyle ':fzf-tab:*' switch-group '<' '>'
# 补全
zinit ice mv="*.zsh -> _fzf" as="completion"
# need junegunn/fzf so as to snippet key-bindings.zsh
zinit snippet "$ZINIT_HOME/plugins/junegunn---fzf/shell/completion.zsh"
zinit snippet "$ZINIT_HOME/plugins/junegunn---fzf/shell/key-bindings.zsh"
zinit ice lucid wait='0'
# https://github.com/bigH/git-fuzzy
zinit ice as"program" pick"bin/git-fuzzy"
zinit light bigH/git-fuzzy
export GF_HORIZONTAL_PREVIEW_PERCENT_CALCULATION='max(50, min(80, 100 - (7000 / __WIDTH__)))'
# {{{ theme
: ${THEME:=p10k}
case $THEME in
pure)
PROMPT=$'\n%F{cyan}❯ %f'
RPROMPT=""
zstyle ':prompt:pure:prompt:success' color cyan
zinit ice lucid wait="!0" pick="async.zsh" src="pure.zsh" atload="prompt_pure_precmd"
zinit light Aloxaf/pure
;;
p10k)
zinit ice depth=1
zinit light romkatv/powerlevel10k
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
;;
starship)
eval "$(starship init zsh)"
;;
esac
# }}}