aboutsummaryrefslogtreecommitdiffstats
path: root/zsh
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2024-09-24 23:54:58 -0400
committerJP Appel <jeanpierre.appel01@gmail.com>2024-09-24 23:54:58 -0400
commitd19967f868445416c5b8005cc57b4ad17d3a4719 (patch)
treec9ba8fa329f577115898ac43de486a033e5762e6 /zsh
parent4bfccb24e8342896081cdfaf17a55f01e81b4766 (diff)
Use current word in fzf file completions
Diffstat (limited to 'zsh')
-rw-r--r--zsh/zshfzf11
1 files changed, 10 insertions, 1 deletions
diff --git a/zsh/zshfzf b/zsh/zshfzf
index 899b69c..dd28049 100644
--- a/zsh/zshfzf
+++ b/zsh/zshfzf
@@ -2,7 +2,16 @@ source <(fzf --zsh)
fzf_widget() {
local selected
- selected=$(fd | fzf --multi --scheme=path\
+ 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' ' ')