Now easy vi-mode possible with fzf #4215
Replies: 2 comments 6 replies
-
Thanks for sharing the idea. That Would it be useful if I made "input section" toggleable? |
Beta Was this translation helpful? Give feedback.
-
Here's part 2. (Little bit advanced?) #!/usr/bin/env bash
fzf \
--no-input \
--bind 'j:down,k:up,/:show-input+unbind(j,k,/,l,g,G,J,K,q)+pos(1)' \
--bind 'enter,esc,ctrl-c:transform:
if [[ $FZF_INPUT_STATE = enabled ]]; then
echo "rebind(j,k,/,l,g,G,J,K,q)+hide-input"
elif [[ $FZF_KEY = enter ]]; then
echo "execute-silent(echo {n} > /tmp/fzf-pos)+accept"
else
echo abort
fi
' $@ Save above script like #!/usr/bin/env bash
FZF_POS="/tmp/fzf-pos"
export FZF_DEFAULT_OPTS+="
--bind='enter,l:execute-silent(echo {n} > \"$FZF_POS\")+accept'
--bind='g:first,G:last,J:page-down,K:page-up,q:abort'
"
while true; do
if [[ -f "$FZF_POS" ]]; then
FZF_LINENO="$(( $(cat "$FZF_POS") + 1 ))"
else
FZF_LINENO="1"
fi
FZF_SEL="$(fd -u -tf -d1 | fzf-vimode "--bind=load:pos:$FZF_LINENO")"
if [[ -f "$FZF_SEL" ]]; then
vim "$FZF_SEL"
else
break
fi
done
rm -f "$FZF_POS" Save above script like Now, I'm finding the way that But this candidate concept also nice.
EDIT: Change order of the actions in |
Beta Was this translation helpful? Give feedback.
-
TLDR. Check @junegunn version of vi-mode 178b498#commitcomment-152030462
Dreams come true.
I used --bind with bunch of "ignore" values like a beast.
But commit 6c0ca4a has --no-input mode.
Still fresh young init idea, but here's proto script.
Save above script like "fzf-vimode", then pipe any command you like.
Search mode with "/" key just like vi, and Escape just do its work.
Add (like "h:become(bash -c viS),l:accept,J:page-down,K:page-up,g:first,G:last"),
or edit fzf args with any value you like.
Potential is all your side.
Here's one example called "fzf-metadata" that I actually use.
With this script, I can check metadata entries for specific files in current directory.
(fd and ffprobe required.)
EDIT 1: Change value
abort+execute
tobecome
#4215 (comment)EDIT 2: Add example "fzf-metadata"
EDIT 3: Add @junegunn version of vi-mode
Beta Was this translation helpful? Give feedback.
All reactions