zshrc: bind '^O' to a custom 'fzf-open' zle widget

This commit is contained in:
surtur 2022-07-03 12:04:48 +02:00
parent af6266010c
commit 085ae5852e
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
2 changed files with 11 additions and 0 deletions

View File

@ -44,3 +44,12 @@ delete-branches() {
fzf --multi --preview="git log {} --" |
xargs --no-run-if-empty git branch --delete --force
}
fzf-open() {
local output
output=$(fzf </dev/tty)
vim --not-a-term ${output}
zle reset-prompt
}
zle -N fzf-open

2
.zshrc
View File

@ -88,9 +88,11 @@
# map arrow up/down to control fish-like history substring search and highlighting
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey '^o' fzf-open
# also map the same keys in 'viins' (INSERT) mode...
bindkey -M viins '^[[A' history-substring-search-up
bindkey -M viins '^[[B' history-substring-search-down
bindkey -M viins '^o' fzf-open
# ...and in 'vicmd' (NORMAL) mode...
bindkey -M vicmd '^[[A' history-substring-search-up
bindkey -M vicmd '^[[B' history-substring-search-down