blob: dd28049a15dd6e5c65584ac5b630e77c87953c98 (
plain) (
blame)
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
|
source <(fzf --zsh)
fzf_widget() {
local selected
local current_word
if [[ "${BUFFER: -1}" == " " ]]; then
current_word=""
else
current_word=$(echo "$BUFFER" | awk '{print $NF}')
BUFFER=${BUFFER%$current_word}
fi
selected=$(fd | fzf --multi --query="$current_word" --scheme=path\
--preview 'preview {} $FZF_PREVIEW_LINES' --preview-label='File Preview' |\
sed 's/^\(.*\)$/"\1"/' | tr '\n' ' ')
if [[ -n $selected ]]; then
BUFFER="$BUFFER$selected"
CURSOR=$#BUFFER
fi
zle redisplay
}
zle -N fzf_widget
bindkey '^f' fzf_widget
|