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