feat(shell): add fzf inline picker bound to @@
Adds __fzf_inline_picker function and @@ keybinding (Emacs + all Vi modes). Opens an fzf session and injects the selected item at the cursor position in the current command line. Includes SYNOPSIS/ DESCRIPTION doc block per project conventions. Updates README with new binding in the User Bindings table.
This commit is contained in:
@@ -222,6 +222,7 @@ Beyond standard shell and FZF bindings, these custom interactive shortcuts are a
|
||||
| `Ctrl+Alt+U` | Replace Command Token | Strips the first token (the command) from the current line. **If the line is empty**, it pulls the previous command and strips its first token, placing the cursor at the start for a quick replacement (e.g., changing `mkdir` to `cd` while keeping the paths). |
|
||||
| `Ctrl+Alt+=` | Inline Qalculate! Evaluation | Passes the current command-line buffer to `qalc` (Qalculate!) and prints the result, then clears the buffer. Allows rapid-fire math without leaving the shell — type `150 * 1.08`, press `Ctrl+Alt+=`, and see `162` immediately. |
|
||||
| `Ctrl+Enter` | Smart Execute | Context-aware Enter key. Empty buffer → standard Enter. Buffer ending with `=` → evaluates it as a math expression via `qalc` (same as `Ctrl+Alt+=`). Any other content → executes the command normally. |
|
||||
| `@@` | FZF Inline Picker | Opens an interactive `fzf` session and injects the selected item directly at the cursor position in the current command line. Useful for inserting file paths, branch names, or any fzf-searchable content mid-command. |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ function fish_user_key_bindings
|
||||
bind ctrl-alt-u _replace_command_token
|
||||
type -q qalc && bind ctrl-alt-= _qalc_eval
|
||||
bind ctrl-enter _smart_execute
|
||||
bind @@ __fzf_inline_picker
|
||||
|
||||
# Set bindings for all Vi modes:
|
||||
# 'default' is Vi-Command, 'insert' is Vi-Insert, 'visual' is Vi-Visual
|
||||
@@ -63,5 +64,6 @@ function fish_user_key_bindings
|
||||
bind --mode $mode ctrl-alt-u _replace_command_token
|
||||
type -q qalc && bind --mode $mode ctrl-alt-= _qalc_eval
|
||||
bind --mode $mode ctrl-enter _smart_execute
|
||||
bind --mode $mode @@ __fzf_inline_picker
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
# SYNOPSIS
|
||||
# __fzf_inline_picker
|
||||
#
|
||||
# DESCRIPTION
|
||||
# Opens an interactive fzf session and injects the selected item directly
|
||||
# into the command line at the cursor position. Bound to @@ by default.
|
||||
# Requires fzf to be installed. Repaints the prompt after insertion.
|
||||
#
|
||||
# RETURNS
|
||||
# 0 A selection was made and inserted into the command line
|
||||
# 0 No selection was made (fzf cancelled); command line is unchanged
|
||||
#
|
||||
# EXAMPLE
|
||||
# # Press @@ at the prompt — fzf opens, pick an item, it appears at cursor
|
||||
#
|
||||
function __fzf_inline_picker
|
||||
# Open fzf and capture selection
|
||||
set -l selection (fzf)
|
||||
|
||||
if test -n "$selection"
|
||||
# Injects text instantly at the cursor
|
||||
commandline -i (string escape -- $selection)
|
||||
end
|
||||
# Refresh the line display
|
||||
commandline -f repaint
|
||||
end
|
||||
Reference in New Issue
Block a user