aboutsummaryrefslogtreecommitdiffstats
path: root/zsh
diff options
context:
space:
mode:
Diffstat (limited to 'zsh')
-rw-r--r--zsh/zshfzf14
-rw-r--r--zsh/zshrc2
2 files changed, 11 insertions, 5 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
diff --git a/zsh/zshrc b/zsh/zshrc
index 4723258..42f5477 100644
--- a/zsh/zshrc
+++ b/zsh/zshrc
@@ -26,7 +26,7 @@ bindkey -v
# Plugins
source ~/.config/zsh/zshvimodes
-eval "$(fzf --zsh)"
+source ~/.config/zsh/zshfzf
# Prompt
setopt PROMPT_SUBST