Files
fish-config/functions/__fzf_inline_picker.fish
T
rootiest 9368a4864c fix(bindings): trigger fzf inline picker with a lookbehind @ instead of a @@ chord
Binding the raw @@ chord made a lone @ an ambiguous prefix, so fish
(with fish_sequence_key_delay_ms unset) held every typed @ indefinitely
until a disambiguating keystroke arrived, breaking things like
`ssh user@host`. Binding the single @ key instead and checking whether
the current token is already a bare @ removes the ambiguity entirely:
plain @ always self-inserts instantly, and a second consecutive @
triggers the picker in place, with no forced delimiter before you can
keep typing. Vi's normal/visual modes are left unbound, matching their
existing (no-op) @ behavior.
2026-08-20 00:38:02 -04:00

34 lines
1.0 KiB
Fish

# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
# SYNOPSIS
# __fzf_inline_picker
#
# 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.
#
# EXIT STATUS
# 0 Always
#
# EXAMPLE
# # Press @ twice at the command prompt to open fzf and insert the
# # selected item in place of the second @, then keep typing to extend it
# # (e.g. a trailing /subdir).
function __fzf_inline_picker
if test (commandline -t) = @
set -l selection (fzf)
if test -n "$selection"
commandline -t -- (string escape -- $selection)
else
commandline -t -- @@
end
commandline -f repaint
else
commandline -i @
end
end