Replace zsh-history-substring-search with fzf
Replace the zsh-history-substring-search plugin with fzf by adding a function that starts the fzf-history-widget when pressing <Up> with a nonempty BUFFER. The widget then uses the buffer automatically as query for fzf.
This commit is contained in:
@@ -26,14 +26,6 @@ zle -N zle-line-finish
|
|||||||
|
|
||||||
bindkey '^[h' run-help
|
bindkey '^[h' run-help
|
||||||
|
|
||||||
## History
|
|
||||||
## Alternatives to check out: {up,down}-line-or-search
|
|
||||||
bindkey '^[[A' history-substring-search-up
|
|
||||||
bindkey "$terminfo[kcuu1]" history-substring-search-up
|
|
||||||
bindkey '^[[B' history-substring-search-down
|
|
||||||
bindkey "$terminfo[kcud1]" history-substring-search-down
|
|
||||||
bindkey '^R' history-incremental-search-backward
|
|
||||||
|
|
||||||
## Navigation
|
## Navigation
|
||||||
bindkey '^[[Z' reverse-menu-complete # shift-tab
|
bindkey '^[[Z' reverse-menu-complete # shift-tab
|
||||||
bindkey '^K' kill-whole-line # ctrl-K
|
bindkey '^K' kill-whole-line # ctrl-K
|
||||||
@@ -83,11 +75,39 @@ function ls-on-enter {
|
|||||||
else
|
else
|
||||||
zle accept-line
|
zle accept-line
|
||||||
fi
|
fi
|
||||||
|
# See fzf-hist below
|
||||||
|
FZF_HIST_WENT_UP=
|
||||||
}
|
}
|
||||||
zle -N ls-on-enter
|
zle -N ls-on-enter
|
||||||
bindkey "^M" ls-on-enter
|
bindkey "^M" ls-on-enter
|
||||||
ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(ls-on-enter)
|
ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(ls-on-enter)
|
||||||
|
|
||||||
|
# "Scroll" through history if buffer was empty but use it as query for fzf over
|
||||||
|
# command line history if not (similar to substring-search but with fzf)
|
||||||
|
function fzf-hist-up {
|
||||||
|
if [ -z "$BUFFER" ] || [ "$FZF_HIST_WENT_UP" -eq 1 ]; then
|
||||||
|
zle up-line-or-history
|
||||||
|
FZF_HIST_WENT_UP=1
|
||||||
|
else
|
||||||
|
# Will take BUFFER as query
|
||||||
|
fzf-history-widget
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
function fzf-hist-down {
|
||||||
|
zle down-line-or-history
|
||||||
|
[ -n "$BUFFER" ] || FZF_HIST_WENT_UP=
|
||||||
|
}
|
||||||
|
zle -N fzf-hist-up
|
||||||
|
zle -N fzf-hist-down
|
||||||
|
|
||||||
|
## History
|
||||||
|
# Up
|
||||||
|
bindkey '^[[A' fzf-hist-up
|
||||||
|
bindkey "$terminfo[kcuu1]" fzf-hist-up
|
||||||
|
# Down
|
||||||
|
bindkey '^[[B' fzf-hist-down
|
||||||
|
bindkey "$terminfo[kcud1]" fzf-hist-down
|
||||||
|
|
||||||
# Fuzzy finder bindings:
|
# Fuzzy finder bindings:
|
||||||
# ^T fzf-file-widget
|
# ^T fzf-file-widget
|
||||||
# \ec (Alt-C) fzf-cd-widget
|
# \ec (Alt-C) fzf-cd-widget
|
||||||
|
|||||||
Submodule .config/zsh/plugins/zsh-history-substring-search deleted from 0f80b8eb33
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -40,9 +40,6 @@
|
|||||||
[submodule ".config/zsh/plugins/zsh-autosuggestions"]
|
[submodule ".config/zsh/plugins/zsh-autosuggestions"]
|
||||||
path = .config/zsh/plugins/zsh-autosuggestions
|
path = .config/zsh/plugins/zsh-autosuggestions
|
||||||
url = https://github.com/zsh-users/zsh-autosuggestions
|
url = https://github.com/zsh-users/zsh-autosuggestions
|
||||||
[submodule ".config/zsh/plugins/zsh-history-substring-search"]
|
|
||||||
path = .config/zsh/plugins/zsh-history-substring-search
|
|
||||||
url = https://github.com/zsh-users/zsh-history-substring-search
|
|
||||||
[submodule ".config/zsh/plugins/zsh-syntax-highlighting"]
|
[submodule ".config/zsh/plugins/zsh-syntax-highlighting"]
|
||||||
path = .config/zsh/plugins/zsh-syntax-highlighting
|
path = .config/zsh/plugins/zsh-syntax-highlighting
|
||||||
url = https://github.com/zsh-users/zsh-syntax-highlighting.git
|
url = https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||||
|
|||||||
Reference in New Issue
Block a user