Mercurial > dotfiles
annotate dot_zshrc @ 540:9036f18c5ad4
restructure zshrc to load all paths before loading plugins
author | zegervdv <zegervdv@me.com> |
---|---|
date | Fri, 28 Jan 2022 09:11:34 +0100 |
parents | 8e2e42add3af |
children | 89769aa79628 |
rev | line source |
---|---|
261 | 1 # vim:ft=zsh |
2 | |
534
aee830df7a88
Add zsh completions for fd and rg
zegervdv <zegervdv@me.com>
parents:
533
diff
changeset
|
3 fpath=(~/.zsh/completions $fpath) |
aee830df7a88
Add zsh completions for fd and rg
zegervdv <zegervdv@me.com>
parents:
533
diff
changeset
|
4 |
293
b29fc37fe1f0
Set TERM to xterm-256color
Zeger Van de Vannet <zegervdv@me.com>
parents:
289
diff
changeset
|
5 export TERM=xterm-256color |
b29fc37fe1f0
Set TERM to xterm-256color
Zeger Van de Vannet <zegervdv@me.com>
parents:
289
diff
changeset
|
6 |
261 | 7 export LC_ALL=$LANG |
8 | |
9 PROMPT='%F{cyan}%T%f %F{red}%m%f %F{blue}%~%b%f | |
265 | 10 %j -> ' |
261 | 11 |
12 | |
265 | 13 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
|
14 vim_cmd_mode="%F{white}%K{red} NRM %k%f" |
261 | 15 vim_mode=$vim_ins_mode |
16 | |
262
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
17 # Cursor mapping from nyquase/vi-mode |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
18 function select_cursor() { |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
19 case $KEYMAP in |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
20 # Block cursor in normal and visual mode |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
21 vicmd) echo -ne "\e[2 q";; |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
22 # Line cursor in insert mode |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
23 main|viins) echo -ne "\e[5 q";; |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
24 # Else Block cursor |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
25 *) echo -ne "\e[2 q";; |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
26 esac |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
27 } |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
28 |
261 | 29 function zle-keymap-select { |
30 vim_mode="${${KEYMAP/vicmd/${vim_cmd_mode}}/(main|viins)/${vim_ins_mode}}" | |
31 zle reset-prompt | |
262
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
32 zle -R |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
33 select_cursor |
261 | 34 } |
35 zle -N zle-keymap-select | |
36 | |
262
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
37 function zle-line-init() { |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
38 echoti smkx |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
39 zle reset-prompt |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
40 select_cursor |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
41 } |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
42 zle -N zle-line-init |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
43 |
261 | 44 function zle-line-finish { |
45 vim_mode=$vim_ins_mode | |
262
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
46 echoti rmkx |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
47 echo -ne "\e[2 q" |
261 | 48 } |
49 zle -N zle-line-finish | |
50 | |
51 function TRAPINT() { | |
52 vim_mode=$vim_ins_mode | |
53 return $(( 128 + $1 )) | |
54 } | |
55 | |
535
f10b89e9aff3
Add git/hg info to zsh prompt
Zeger Van de Vannet <zegervdv@me.com>
parents:
534
diff
changeset
|
56 autoload -Uz vcs_info |
f10b89e9aff3
Add git/hg info to zsh prompt
Zeger Van de Vannet <zegervdv@me.com>
parents:
534
diff
changeset
|
57 zstyle ':vcs_info:*' enable git hg |
f10b89e9aff3
Add git/hg info to zsh prompt
Zeger Van de Vannet <zegervdv@me.com>
parents:
534
diff
changeset
|
58 |
f10b89e9aff3
Add git/hg info to zsh prompt
Zeger Van de Vannet <zegervdv@me.com>
parents:
534
diff
changeset
|
59 zstyle ':vcs_info:*' actionformats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f ' |
f10b89e9aff3
Add git/hg info to zsh prompt
Zeger Van de Vannet <zegervdv@me.com>
parents:
534
diff
changeset
|
60 zstyle ':vcs_info:*' formats '%F{4}%s%F{5}%F{3} @ %F{2}%b%f' |
f10b89e9aff3
Add git/hg info to zsh prompt
Zeger Van de Vannet <zegervdv@me.com>
parents:
534
diff
changeset
|
61 zstyle ':vcs_info:hg*:*' use-simple true |
f10b89e9aff3
Add git/hg info to zsh prompt
Zeger Van de Vannet <zegervdv@me.com>
parents:
534
diff
changeset
|
62 |
f10b89e9aff3
Add git/hg info to zsh prompt
Zeger Van de Vannet <zegervdv@me.com>
parents:
534
diff
changeset
|
63 precmd () { vcs_info } |
f10b89e9aff3
Add git/hg info to zsh prompt
Zeger Van de Vannet <zegervdv@me.com>
parents:
534
diff
changeset
|
64 |
f10b89e9aff3
Add git/hg info to zsh prompt
Zeger Van de Vannet <zegervdv@me.com>
parents:
534
diff
changeset
|
65 RPROMPT='${vcs_info_msg_0_} ${vim_mode}' |
261 | 66 |
67 zmodload -i zsh/complist | |
68 | |
69 bindkey -v | |
70 | |
262
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
71 bindkey '^[[A' history-substring-search-up |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
72 bindkey '^[[B' history-substring-search-down |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
73 bindkey "$terminfo[kcuu1]" history-substring-search-up |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
74 bindkey "$terminfo[kcud1]" history-substring-search-down |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
75 bindkey '^p' history-substring-search-up |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
76 bindkey '^n' history-substring-search-down |
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
77 |
533
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
78 bindkey '^f' autosuggest-accept |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
79 |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
80 zmodload zsh/complist |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
81 bindkey -M menuselect 'h' vi-backward-char |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
82 bindkey -M menuselect 'k' vi-up-line-or-history |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
83 bindkey -M menuselect 'j' vi-down-line-or-history |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
84 bindkey -M menuselect 'l' vi-forward-char |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
85 |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
86 # Enter interactive search |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
87 bindkey -M menuselect '^xi' vi-insert |
531 | 88 |
263 | 89 export LESS_TERMCAP_mb=$(printf "\e[1;31m") |
90 export LESS_TERMCAP_md=$(printf "\e[1;31m") | |
91 export LESS_TERMCAP_me=$(printf "\e[0m") | |
92 export LESS_TERMCAP_se=$(printf "\e[0m") | |
93 export LESS_TERMCAP_so=$(printf "\e[1;44;33m") | |
94 export LESS_TERMCAP_ue=$(printf "\e[0m") | |
95 export LESS_TERMCAP_us=$(printf "\e[1;32m") | |
262
44d179225271
Add history substring search plugin
zegervdv <zegervdv@me.com>
parents:
261
diff
changeset
|
96 |
261 | 97 export CLICOLOR=1 |
98 export LS_COLORS='no=00;37:fi=00:di=00;33:ln=04;36:pi=40;33:so=01;35:bd=40;33;01:' | |
99 | |
100 # Options | |
101 setopt monitor | |
102 setopt auto_cd | |
103 setopt cdablevars | |
104 setopt pushd_ignore_dups | |
105 setopt interactive_comments | |
106 setopt append_history | |
107 setopt inc_append_history | |
108 setopt hist_ignore_dups | |
109 setopt hist_find_no_dups | |
110 setopt hist_reduce_blanks | |
111 setopt extended_history | |
112 setopt hist_expire_dups_first | |
113 setopt hist_verify | |
114 setopt share_history | |
115 setopt transient_rprompt | |
116 setopt prompt_subst | |
117 setopt multios | |
118 setopt correct_all | |
119 setopt autopushd | |
120 setopt pushdminus | |
121 setopt pushdsilent | |
122 setopt nobeep | |
123 setopt notify | |
124 REPORTTIME=5 | |
125 | |
126 HISTSIZE=3000 | |
127 SAVEHIST=3000 | |
128 HISTFILE=~/.zsh_history | |
129 | |
130 # Completion | |
131 setopt complete_in_word | |
132 setopt always_to_end | |
133 setopt auto_menu | |
533
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
134 setopt auto_param_slash |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
135 |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
136 # Enable completers |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
137 zstyle ':completion:*' completer _complete _approximate |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
138 |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
139 zstyle ':completion:*' use-cache on |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
140 zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/.zcompcache" |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
141 |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
142 # file list info |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
143 zstyle ':completion:*' file-list list |
261 | 144 |
145 # activate color-completion | |
533
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
146 zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} |
261 | 147 |
148 # format on completion | |
533
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
149 zstyle ':completion:*:descriptions' format $'%{\e[0;31m%}completing %B%d%b%{\e[0m%}' |
261 | 150 |
151 # insert all expansions for expand completer | |
533
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
152 zstyle ':completion:*:expand:*' tag-order all-expansions |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
153 zstyle ':completion:*:history-words' list false |
261 | 154 |
155 # activate menu | |
533
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
156 zstyle ':completion:*:history-words' menu yes |
261 | 157 |
158 # ignore duplicate entries | |
533
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
159 zstyle ':completion:*:history-words' remove-all-dups yes |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
160 zstyle ':completion:*:history-words' stop yes |
261 | 161 |
533
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
162 zstyle ':completion:*:matches' group 'yes' |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
163 zstyle ':completion:*' group-name '' |
261 | 164 if [[ "$NOMENU" -eq 0 ]] ; then |
165 # if there are more than 5 options allow selecting from a menu | |
533
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
166 zstyle ':completion:*' menu select=5 |
261 | 167 else |
168 # don't use any menus at all | |
169 setopt no_auto_menu | |
170 fi | |
171 | |
533
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
172 zstyle ':completion:*:messages' format '%d' |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
173 zstyle ':completion:*:options' auto-description '%d' |
261 | 174 |
175 # describe options in full | |
533
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
176 zstyle ':completion:*:options' description 'yes' |
261 | 177 |
178 # complete manual by their section | |
533
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
179 zstyle ':completion:*:manuals' separate-sections true |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
180 zstyle ':completion:*:manuals.*' insert-sections true |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
181 zstyle ':completion:*:man:*' menu yes select |
261 | 182 |
183 # Search path for sudo completion | |
184 zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \ | |
185 /usr/local/bin \ | |
186 /usr/sbin \ | |
187 /usr/bin \ | |
188 /sbin \ | |
189 /bin \ | |
190 /usr/X11R6/bin | |
191 | |
192 # provide .. as a completion | |
193 zstyle ':completion:*' specal-dirs .. | |
194 | |
195 # case insensitive path-completion | |
196 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:|=*' | |
197 | |
198 # nvim completion | |
533
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
199 zstyle ':completion:*:*:nvim:*' ignored-patterns '*.(o|hex|elf|pyc|pdf|dup)' |
22fb4745cb1b
set more completion options in zsh
Zeger Van de Vannet <zegervdv@me.com>
parents:
531
diff
changeset
|
200 zstyle ':completion:*:*:nvim:*' file-sort modification |
261 | 201 |
202 autoload -U compinit && compinit | |
203 | |
204 # fg when pressing Ctrl+Z | |
205 function fancy-ctrl-z () { | |
206 if [[ $#BUFFER -eq 0 ]]; then | |
207 if [[ $(jobs | wc -l) -gt 0 ]]; then | |
208 BUFFER='fg' | |
209 zle accept-line | |
210 fi | |
211 else | |
212 zle push-input | |
213 zle clear-screen | |
214 fi | |
215 } | |
216 zle -N fancy-ctrl-z | |
217 bindkey '^Z' fancy-ctrl-z | |
218 | |
219 # Aliases | |
479 | 220 alias l="ls -haltr" |
221 alias ll="ls -haltr" | |
261 | 222 alias xclip='xclip -selection clipboard' |
269 | 223 alias view='nvim -R' |
261 | 224 |
225 # Exports | |
226 export XDG_CONFIG_HOME=$HOME/.config | |
227 export PATH=$HOME/bin:$PATH | |
228 | |
229 export EDITOR=nvim | |
230 export HGEDITOR=nvim | |
231 | |
504 | 232 export RIPGREP_CONFIG_PATH=$HOME/.config/ripgrep/ripgreprc |
506 | 233 export BAT_CONFIG_PATH=$HOME/.config/bat/config |
504 | 234 |
267 | 235 [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh |
539 | 236 |
540
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
237 bindkey '^t' push-line-or-edit |
539 | 238 |
267 | 239 [ -f ~/.zshrc.local ] && source ~/.zshrc.local |
491
f1d1eab204aa
Fix paths to nvim for SUDO_EDITOR
zegervdv <zegervdv@me.com>
parents:
490
diff
changeset
|
240 |
f1d1eab204aa
Fix paths to nvim for SUDO_EDITOR
zegervdv <zegervdv@me.com>
parents:
490
diff
changeset
|
241 # Must run after brew is loaded |
f1d1eab204aa
Fix paths to nvim for SUDO_EDITOR
zegervdv <zegervdv@me.com>
parents:
490
diff
changeset
|
242 export SUDO_EDITOR=$(which nvim) |
508 | 243 eval "$(direnv hook zsh)" |
540
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
244 |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
245 source ~/.zsh/zsh-history-substring-search.zsh |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
246 export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=green,fg=black' |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
247 |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
248 source ~/.zsh/zsh-autosuggestions.zsh |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
249 |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
250 source ~/.zsh/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
251 |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
252 source ~/.zsh/zsh-histdb/sqlite-history.zsh |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
253 source ~/.zsh/fzf-histdb.zsh |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
254 |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
255 bindkey '^r' histdb-fzf-widget |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
256 |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
257 _zsh_autosuggest_strategy_histdb_top_here() { |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
258 local query="select commands.argv from |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
259 history left join commands on history.command_id = commands.rowid |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
260 left join places on history.place_id = places.rowid |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
261 where places.dir LIKE '$(sql_escape $PWD)%' |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
262 and commands.argv LIKE '$(sql_escape $1)%' |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
263 group by commands.argv order by count(*) desc limit 1" |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
264 suggestion=$(_histdb_query "$query") |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
265 } |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
266 |
9036f18c5ad4
restructure zshrc to load all paths before loading plugins
zegervdv <zegervdv@me.com>
parents:
539
diff
changeset
|
267 ZSH_AUTOSUGGEST_STRATEGY=histdb_top_here |