aboutsummaryrefslogtreecommitdiffstats
path: root/zsh/zshfzf
diff options
context:
space:
mode:
Diffstat (limited to 'zsh/zshfzf')
-rw-r--r--zsh/zshfzf14
1 files changed, 10 insertions, 4 deletions
diff --git a/zsh/zshfzf b/zsh/zshfzf
index ff6e061..899b69c 100644
--- a/zsh/zshfzf
+++ b/zsh/zshfzf
@@ -1,10 +1,16 @@
source <(fzf --zsh)
fzf_widget() {
- BUFFER=$(fd | fzf --multi --scheme=path\
- --preview 'preview {} $FZF_PREVIEW_LINES' --preview-label='File Preview')
- CURSOR=$#BUFFER
- zle redisplay
+ local selected
+ selected=$(fd | fzf --multi --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