fix(bindings): trigger fzf inline picker with a lookbehind @ instead of a @@ chord #108
@@ -65,7 +65,6 @@ function fish_user_key_bindings
|
|||||||
bind ctrl-alt-u _replace_command_token
|
bind ctrl-alt-u _replace_command_token
|
||||||
type -q qalc && bind ctrl-alt-= _qalc_eval
|
type -q qalc && bind ctrl-alt-= _qalc_eval
|
||||||
bind ctrl-enter _smart_execute
|
bind ctrl-enter _smart_execute
|
||||||
bind @@ __fzf_inline_picker
|
|
||||||
bind ctrl-right nextd-or-forward-word
|
bind ctrl-right nextd-or-forward-word
|
||||||
bind \e\[1\;5C nextd-or-forward-word
|
bind \e\[1\;5C nextd-or-forward-word
|
||||||
|
|
||||||
@@ -77,8 +76,17 @@ function fish_user_key_bindings
|
|||||||
bind --mode $mode ctrl-alt-u _replace_command_token
|
bind --mode $mode ctrl-alt-u _replace_command_token
|
||||||
type -q qalc && bind --mode $mode ctrl-alt-= _qalc_eval
|
type -q qalc && bind --mode $mode ctrl-alt-= _qalc_eval
|
||||||
bind --mode $mode ctrl-enter _smart_execute
|
bind --mode $mode ctrl-enter _smart_execute
|
||||||
bind --mode $mode @@ __fzf_inline_picker
|
|
||||||
bind --mode $mode ctrl-right nextd-or-forward-word
|
bind --mode $mode ctrl-right nextd-or-forward-word
|
||||||
bind --mode $mode \e\[1\;5C nextd-or-forward-word
|
bind --mode $mode \e\[1\;5C nextd-or-forward-word
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @ is Emacs/Vi-insert only. Emacs bindings and Vi's "default" (normal)
|
||||||
|
# mode share the same bind_mode name, so a mode-less `bind @` would also
|
||||||
|
# land in Vi normal mode, turning its current no-op @ into a self-insert.
|
||||||
|
# Register the mode-less form only when Vi bindings aren't the active
|
||||||
|
# base, and rely on the explicit insert-mode bind otherwise.
|
||||||
|
if test "$fish_key_bindings" != fish_vi_key_bindings
|
||||||
|
bind @ __fzf_inline_picker
|
||||||
|
end
|
||||||
|
bind --mode insert @ __fzf_inline_picker
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -42,9 +42,11 @@ are active in Insert, Normal, and Visual modes unless noted.
|
|||||||
pressing Enter a second time for certain fast-path
|
pressing Enter a second time for certain fast-path
|
||||||
commands (speedtest-fast, etc.).
|
commands (speedtest-fast, etc.).
|
||||||
|
|
||||||
@@ FZF inline picker. Type @@ anywhere on the command
|
@@ FZF inline picker. Type @ twice anywhere on the
|
||||||
line to open an fzf picker and insert a selection
|
command line to open an fzf picker and replace the
|
||||||
at the cursor position.
|
@@ with the selection. The @@ must be typed as its
|
||||||
|
own token: "cat @@" triggers it, but "cat@@" does
|
||||||
|
not.
|
||||||
|
|
||||||
Ctrl+Right Accept autosuggestion one word/directory segment
|
Ctrl+Right Accept autosuggestion one word/directory segment
|
||||||
at a time. (Restores Fish 3.x behavior by binding
|
at a time. (Restores Fish 3.x behavior by binding
|
||||||
|
|||||||
@@ -5,23 +5,29 @@
|
|||||||
# __fzf_inline_picker
|
# __fzf_inline_picker
|
||||||
#
|
#
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
# Opens an interactive fzf session and injects the selected item directly
|
# Bound to the @ key. Self-inserts @ normally; on a second consecutive @
|
||||||
# into the command line at the cursor position. Bound to @@ by default.
|
# (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.
|
# Repaints the prompt after selection or cancellation.
|
||||||
#
|
#
|
||||||
# EXIT STATUS
|
# EXIT STATUS
|
||||||
# 0 Always; no-op if fzf is cancelled
|
# 0 Always
|
||||||
#
|
#
|
||||||
# EXAMPLE
|
# EXAMPLE
|
||||||
# # Press @@ at the command prompt to open fzf and insert the selected item.
|
# # 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
|
function __fzf_inline_picker
|
||||||
# Open fzf and capture selection
|
if test (commandline -t) = @
|
||||||
set -l selection (fzf)
|
set -l selection (fzf)
|
||||||
|
if test -n "$selection"
|
||||||
if test -n "$selection"
|
commandline -t -- (string escape -- $selection)
|
||||||
# Injects text instantly at the cursor
|
else
|
||||||
commandline -i (string escape -- $selection)
|
commandline -t -- @@
|
||||||
|
end
|
||||||
|
commandline -f repaint
|
||||||
|
else
|
||||||
|
commandline -i @
|
||||||
end
|
end
|
||||||
# Refresh the line display
|
|
||||||
commandline -f repaint
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user