feat(fzf): add preview, dirs, and image support to @@ inline picker
The @@ picker only listed files with no preview. It now lists both files and directories via fd (matching _fzf_search_directory), and shows a bat-highlighted or image-rendered preview through _fzf_preview_file. Image previews use a kitty-graphics-protocol, chafa, viu, timg fallback chain via the new _fzf_preview_image helper, benefiting the Ctrl+F directory search and git-status pickers as well since they share the same preview helper.
This commit is contained in:
@@ -7,9 +7,12 @@
|
||||
# DESCRIPTION
|
||||
# Bound to the @ key. Self-inserts @ normally; on a second consecutive @
|
||||
# (detected by looking behind at the current token rather than making fish
|
||||
# buffer ahead for a chord), opens an interactive fzf session and replaces
|
||||
# the bare @ with the selected item. Cancelling leaves a literal @@ behind.
|
||||
# Repaints the prompt after selection or cancellation.
|
||||
# buffer ahead for a chord), opens an interactive fzf session listing both
|
||||
# files and directories under the current directory, with a preview pane
|
||||
# (bat-highlighted for text, image-rendered for pictures via
|
||||
# _fzf_preview_file), and replaces the bare @ with the selected item.
|
||||
# Cancelling leaves a literal @@ behind. Repaints the prompt after
|
||||
# selection or cancellation.
|
||||
#
|
||||
# EXIT STATUS
|
||||
# 0 Always
|
||||
@@ -20,7 +23,22 @@
|
||||
# # (e.g. a trailing /subdir).
|
||||
function __fzf_inline_picker
|
||||
if test (commandline -t) = @
|
||||
set -l selection (fzf)
|
||||
# Directly use fd binary to avoid output buffering delay caused by a fd
|
||||
# alias, if any. Debian-based distros install fd as fdfind.
|
||||
set -f fd_cmd (command -v fdfind || command -v fd || echo "fd")
|
||||
set -f --append fd_cmd --color=always $fzf_fd_opts
|
||||
|
||||
set -l selection ($fd_cmd 2>/dev/null | _fzf_wrapper --ansi \
|
||||
--height=90% \
|
||||
--layout=reverse \
|
||||
--border=rounded \
|
||||
--border-label=' Insert Path ' \
|
||||
--prompt='@@ -> ' \
|
||||
--header='Enter: Insert Ctrl-/: Toggle Preview Esc: Cancel' \
|
||||
--bind='ctrl-/:toggle-preview' \
|
||||
--preview='_fzf_preview_file {}' \
|
||||
--preview-window='right:50%:wrap:border-left')
|
||||
|
||||
if test -n "$selection"
|
||||
commandline -t -- (string escape -- $selection)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user