Mercurial > dotfiles
annotate dot_zshrc @ 505:38b7afc9e492
Add tmux plugins
author | zegervdv <zegervdv@me.com> |
---|---|
date | Mon, 13 Dec 2021 12:16:59 +0100 |
parents | 1403bfc694e4 |
children | 36ba70d17fd6 |
rev | line source |
---|---|
261 | 1 # vim:ft=zsh |
2 | |
262
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
3 source ~/.zsh/zsh-history-substring-search.zsh |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
4 export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=green,fg=black' |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
5 |
293
b29fc37fe1f0
Set TERM to xterm-256color
Zeger Van de Vannet <zegervdv@me.com>
parents:
289
diff
changeset
|
6 export TERM=xterm-256color |
b29fc37fe1f0
Set TERM to xterm-256color
Zeger Van de Vannet <zegervdv@me.com>
parents:
289
diff
changeset
|
7 |
261 | 8 export LC_ALL=$LANG |
9 | |
10 PROMPT='%F{cyan}%T%f %F{red}%m%f %F{blue}%~%b%f | |
265 | 11 %j -> ' |
261 | 12 |
13 | |
265 | 14 vim_ins_mode="%F{black}%K{yellow} INS %k%f" |
266
7a275f0d38e8
Use red to indicate Normal mode in zsh prompt
zegervdv <zegervdv@me.com>
parents:
265
diff
changeset
|
15 vim_cmd_mode="%F{white}%K{red} NRM %k%f" |
261 | 16 vim_mode=$vim_ins_mode |
17 | |
262
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
18 # Cursor mapping from nyquase/vi-mode |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
19 function select_cursor() { |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
20 case $KEYMAP in |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
21 # Block cursor in normal and visual mode |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
22 vicmd) echo -ne "\e[2 q";; |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
23 # Line cursor in insert mode |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
24 main|viins) echo -ne "\e[5 q";; |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
25 # Else Block cursor |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
26 *) echo -ne "\e[2 q";; |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
27 esac |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
28 } |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
29 |
261 | 30 function zle-keymap-select { |
31 vim_mode="${${KEYMAP/vicmd/${vim_cmd_mode}}/(main|viins)/${vim_ins_mode}}" | |
32 zle reset-prompt | |
262
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
33 zle -R |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
34 select_cursor |
261 | 35 } |
36 zle -N zle-keymap-select | |
37 | |
262
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
38 function zle-line-init() { |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
39 echoti smkx |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
40 zle reset-prompt |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
41 select_cursor |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
42 } |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
43 zle -N zle-line-init |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
44 |
261 | 45 function zle-line-finish { |
46 vim_mode=$vim_ins_mode | |
262
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
47 echoti rmkx |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
48 echo -ne "\e[2 q" |
261 | 49 } |
50 zle -N zle-line-finish | |
51 | |
52 function TRAPINT() { | |
53 vim_mode=$vim_ins_mode | |
54 return $(( 128 + $1 )) | |
55 } | |
56 | |
57 RPROMPT='${vim_mode}' | |
58 | |
59 zmodload -i zsh/complist | |
60 | |
61 bindkey -v | |
62 | |
262
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
63 bindkey '^[[A' history-substring-search-up |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
64 bindkey '^[[B' history-substring-search-down |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
65 bindkey "$terminfo[kcuu1]" history-substring-search-up |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
66 bindkey "$terminfo[kcud1]" history-substring-search-down |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
67 bindkey '^p' history-substring-search-up |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
68 bindkey '^n' history-substring-search-down |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
69 |
263 | 70 export LESS_TERMCAP_mb=$(printf "\e[1;31m") |
71 export LESS_TERMCAP_md=$(printf "\e[1;31m") | |
72 export LESS_TERMCAP_me=$(printf "\e[0m") | |
73 export LESS_TERMCAP_se=$(printf "\e[0m") | |
74 export LESS_TERMCAP_so=$(printf "\e[1;44;33m") | |
75 export LESS_TERMCAP_ue=$(printf "\e[0m") | |
76 export LESS_TERMCAP_us=$(printf "\e[1;32m") | |
262
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
77 |
261 | 78 export CLICOLOR=1 |
79 export LS_COLORS='no=00;37:fi=00:di=00;33:ln=04;36:pi=40;33:so=01;35:bd=40;33;01:' | |
80 | |
81 # Options | |
82 setopt monitor | |
83 setopt auto_cd | |
84 setopt cdablevars | |
85 setopt pushd_ignore_dups | |
86 setopt interactive_comments | |
87 setopt append_history | |
88 setopt inc_append_history | |
89 setopt hist_ignore_dups | |
90 setopt hist_find_no_dups | |
91 setopt hist_reduce_blanks | |
92 setopt extended_history | |
93 setopt hist_expire_dups_first | |
94 setopt hist_verify | |
95 setopt share_history | |
96 setopt transient_rprompt | |
97 setopt prompt_subst | |
98 setopt multios | |
99 setopt correct_all | |
100 setopt autopushd | |
101 setopt pushdminus | |
102 setopt pushdsilent | |
103 setopt nobeep | |
104 setopt notify | |
105 REPORTTIME=5 | |
106 | |
107 HISTSIZE=3000 | |
108 SAVEHIST=3000 | |
109 HISTFILE=~/.zsh_history | |
110 | |
111 # Completion | |
112 setopt complete_in_word | |
113 setopt always_to_end | |
114 setopt auto_menu | |
115 | |
116 # activate color-completion | |
117 zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} | |
118 | |
119 # format on completion | |
120 zstyle ':completion:*:descriptions' format $'%{\e[0;31m%}completing %B%d%b%{\e[0m%}' | |
121 | |
122 # insert all expansions for expand completer | |
123 zstyle ':completion:*:expand:*' tag-order all-expansions | |
124 zstyle ':completion:*:history-words' list false | |
125 | |
126 # activate menu | |
127 zstyle ':completion:*:history-words' menu yes | |
128 | |
129 # ignore duplicate entries | |
130 zstyle ':completion:*:history-words' remove-all-dups yes | |
131 zstyle ':completion:*:history-words' stop yes | |
132 | |
133 zstyle ':completion:*:matches' group 'yes' | |
134 zstyle ':completion:*' group-name '' | |
135 if [[ "$NOMENU" -eq 0 ]] ; then | |
136 # if there are more than 5 options allow selecting from a menu | |
137 zstyle ':completion:*' menu select=5 | |
138 else | |
139 # don't use any menus at all | |
140 setopt no_auto_menu | |
141 fi | |
142 | |
143 zstyle ':completion:*:messages' format '%d' | |
144 zstyle ':completion:*:options' auto-description '%d' | |
145 | |
146 # describe options in full | |
147 zstyle ':completion:*:options' description 'yes' | |
148 | |
149 # complete manual by their section | |
150 zstyle ':completion:*:manuals' separate-sections true | |
151 zstyle ':completion:*:manuals.*' insert-sections true | |
152 zstyle ':completion:*:man:*' menu yes select | |
153 | |
154 # Search path for sudo completion | |
155 zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \ | |
156 /usr/local/bin \ | |
157 /usr/sbin \ | |
158 /usr/bin \ | |
159 /sbin \ | |
160 /bin \ | |
161 /usr/X11R6/bin | |
162 | |
163 # provide .. as a completion | |
164 zstyle ':completion:*' specal-dirs .. | |
165 | |
166 # case insensitive path-completion | |
167 zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' | |
168 | |
169 # nvim completion | |
170 zstyle ':completion::*:nvim:*' ignored-patterns '*.(o|hex|elf|pyc|pdf|dup)' | |
171 | |
172 autoload -U compinit && compinit | |
173 | |
174 # fg when pressing Ctrl+Z | |
175 function fancy-ctrl-z () { | |
176 if [[ $#BUFFER -eq 0 ]]; then | |
177 if [[ $(jobs | wc -l) -gt 0 ]]; then | |
178 BUFFER='fg' | |
179 zle accept-line | |
180 fi | |
181 else | |
182 zle push-input | |
183 zle clear-screen | |
184 fi | |
185 } | |
186 zle -N fancy-ctrl-z | |
187 bindkey '^Z' fancy-ctrl-z | |
188 | |
300
c49fb04cf6da
Autocomplete rg search terms with ctags data
zegervdv <zegervdv@me.com>
parents:
293
diff
changeset
|
189 # Ctags based completion for rg |
c49fb04cf6da
Autocomplete rg search terms with ctags data
zegervdv <zegervdv@me.com>
parents:
293
diff
changeset
|
190 _rg() { |
c49fb04cf6da
Autocomplete rg search terms with ctags data
zegervdv <zegervdv@me.com>
parents:
293
diff
changeset
|
191 if (( CURRENT == 2 )); then |
c49fb04cf6da
Autocomplete rg search terms with ctags data
zegervdv <zegervdv@me.com>
parents:
293
diff
changeset
|
192 compadd $(cut -f 1 tags tmp/tags 2>/dev/null | grep -v '!_TAG') |
c49fb04cf6da
Autocomplete rg search terms with ctags data
zegervdv <zegervdv@me.com>
parents:
293
diff
changeset
|
193 fi |
c49fb04cf6da
Autocomplete rg search terms with ctags data
zegervdv <zegervdv@me.com>
parents:
293
diff
changeset
|
194 } |
c49fb04cf6da
Autocomplete rg search terms with ctags data
zegervdv <zegervdv@me.com>
parents:
293
diff
changeset
|
195 |
c49fb04cf6da
Autocomplete rg search terms with ctags data
zegervdv <zegervdv@me.com>
parents:
293
diff
changeset
|
196 compdef _rg rg |
c49fb04cf6da
Autocomplete rg search terms with ctags data
zegervdv <zegervdv@me.com>
parents:
293
diff
changeset
|
197 |
261 | 198 # Aliases |
479 | 199 alias l="ls -haltr" |
200 alias ll="ls -haltr" | |
261 | 201 alias xclip='xclip -selection clipboard' |
269 | 202 alias view='nvim -R' |
261 | 203 |
204 # Exports | |
205 export XDG_CONFIG_HOME=$HOME/.config | |
206 export PATH=$HOME/bin:$PATH | |
207 | |
208 export EDITOR=nvim | |
209 export HGEDITOR=nvim | |
210 | |
504 | 211 export RIPGREP_CONFIG_PATH=$HOME/.config/ripgrep/ripgreprc |
212 | |
267 | 213 [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh |
261 | 214 export FZF_DEFAULT_COMMAND='ag -g ""' |
267 | 215 [ -f ~/.zshrc.local ] && source ~/.zshrc.local |
491
f1d1eab204aa
Fix paths to nvim for SUDO_EDITOR
zegervdv <zegervdv@me.com>
parents:
490
diff
changeset
|
216 |
f1d1eab204aa
Fix paths to nvim for SUDO_EDITOR
zegervdv <zegervdv@me.com>
parents:
490
diff
changeset
|
217 # Must run after brew is loaded |
f1d1eab204aa
Fix paths to nvim for SUDO_EDITOR
zegervdv <zegervdv@me.com>
parents:
490
diff
changeset
|
218 export SUDO_EDITOR=$(which nvim) |