-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathzsh-hist.plugin.zsh
38 lines (30 loc) · 900 Bytes
/
zsh-hist.plugin.zsh
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
#!/bin/zsh
unsetopt flowcontrol
zsh-hist() {
emulate -L zsh -o extendedglob -o rcquotes -o noshortloops -o warncreateglobal
local dir=${${(%):-%x}:P:h}
local fdir=$dir/functions
typeset -gU FPATH fpath=( $dir $fpath )
# Work around https://github.com/zdharma/zinit/issues/441
builtin autoload -Uz $fdir/hist $fdir/.hist.*~*.zwc
bindkey -M 'emacs' '^Q' push-history
bindkey -M 'viins' '^Q' push-history
bindkey -M 'vicmd' '^Q' push-history
zle -N push-history .hist.push-history.widget
zle -N undo .hist.undo.widget
autoload -Uz add-zsh-hook
:hist:precmd() {
local 0=${(%):-%N}
add-zsh-hook -d precmd $0
unfunction $0
autoload -Uz add-zle-hook-widget
add-zle-hook-widget line-init .hist.format.hook
add-zle-hook-widget line-finish .hist.format.hook
}
add-zsh-hook precmd :hist:precmd
}
{
zsh-hist "$@"
} always {
unfunction zsh-hist
}