fix(keybinds): guard bindings on required binaries and fix fzf compat #16

Merged
rootiest merged 5 commits from fix/fzf-keybind-guards into main 2026-05-19 00:56:30 +00:00
Owner

Summary

Two categories of fixes, both motivated by compatibility with older fzf builds (e.g. fzf 0.60 devel on the home server).

Binary guards for optional tools

Keybindings that depend on optional tools are now only registered when those tools are present in PATH. Previously, pressing the key on a machine without the tool would error rather than silently do nothing.

File Change
conf.d/fzf.fish Skip fzf_configure_bindings if fzf is not in PATH
conf.d/key_bindings.fish Guard Ctrl+Alt+= (both emacs and vi modes) with type -q qalc
functions/_qalc_eval.fish Return 1 early if qalc is absent
functions/_smart_execute.fish Fall back to normal execute when _qalc_eval returns 1

fzf version compatibility for fzf-history-widget

Several options used in integrations/fzf.fish were added after fzf 0.60. The fzf version is detected once at shell startup inside fzf_key_bindings and captured into fzf-history-widget via --inherit-variable. All newer-only options are gated behind a single if test "$_fzf_transform_action" = bg-transform block.

Option Older fzf (< 0.62) Newer fzf (≥ 0.62)
Transform action transform (sync) bg-transform (non-blocking)
Preview wrap wrap wrap-word
Preview wrap sign (omitted) --preview-wrap-sign="↳ "
Alt-R bind (omitted) alt-r:toggle-raw

Manual Verification Checklist

  • With fzf installed (new): Press Ctrl+R — history picker opens normally with working preview pane.
  • Without fzf installed: Start a fresh shell — no errors on startup; Ctrl+R/Ctrl+T/Alt+C produce no binding errors.
  • With qalc installed: Type 150 * 1.08 and press Ctrl+Alt+= — result printed, buffer clears. Type 2+2= and press Ctrl+Enter — result printed.
  • Without qalc installed: Fresh shell has no errors; Ctrl+Alt+= does nothing; Ctrl+Enter on a *=-ending buffer executes the line normally.
  • On fzf 0.60 devel: Press Ctrl+R — history picker opens with no unknown action or unknown option errors in stderr.
## Summary Two categories of fixes, both motivated by compatibility with older fzf builds (e.g. fzf 0.60 devel on the home server). ### Binary guards for optional tools Keybindings that depend on optional tools are now only registered when those tools are present in `PATH`. Previously, pressing the key on a machine without the tool would error rather than silently do nothing. | File | Change | |---|---| | `conf.d/fzf.fish` | Skip `fzf_configure_bindings` if `fzf` is not in PATH | | `conf.d/key_bindings.fish` | Guard Ctrl+Alt+= (both emacs and vi modes) with `type -q qalc` | | `functions/_qalc_eval.fish` | Return 1 early if `qalc` is absent | | `functions/_smart_execute.fish` | Fall back to normal execute when `_qalc_eval` returns 1 | ### fzf version compatibility for `fzf-history-widget` Several options used in `integrations/fzf.fish` were added after fzf 0.60. The fzf version is detected once at shell startup inside `fzf_key_bindings` and captured into `fzf-history-widget` via `--inherit-variable`. All newer-only options are gated behind a single `if test "$_fzf_transform_action" = bg-transform` block. | Option | Older fzf (< 0.62) | Newer fzf (≥ 0.62) | |---|---|---| | Transform action | `transform` (sync) | `bg-transform` (non-blocking) | | Preview wrap | `wrap` | `wrap-word` | | Preview wrap sign | *(omitted)* | `--preview-wrap-sign="↳ "` | | Alt-R bind | *(omitted)* | `alt-r:toggle-raw` | ## Manual Verification Checklist - [x] **With fzf installed (new)**: Press Ctrl+R — history picker opens normally with working preview pane. - [x] **Without fzf installed**: Start a fresh shell — no errors on startup; Ctrl+R/Ctrl+T/Alt+C produce no binding errors. - [x] **With qalc installed**: Type `150 * 1.08` and press Ctrl+Alt+= — result printed, buffer clears. Type `2+2=` and press Ctrl+Enter — result printed. - [x] **Without qalc installed**: Fresh shell has no errors; Ctrl+Alt+= does nothing; Ctrl+Enter on a `*=`-ending buffer executes the line normally. - [x] **On fzf 0.60 devel**: Press Ctrl+R — history picker opens with no `unknown action` or `unknown option` errors in stderr.
rootiest added 2 commits 2026-05-19 00:41:09 +00:00
- conf.d/fzf.fish: skip fzf_configure_bindings if fzf is not in PATH
- key_bindings.fish: only bind Ctrl+Alt+= when qalc is installed
- _qalc_eval: return 1 early if qalc is absent so callers can react
- _smart_execute: fall back to normal execute when _qalc_eval returns 1
- integrations/fzf.fish: replace bg-transform with transform (available
  since fzf 0.53; bg-transform requires a newer version and caused
  "unknown action" errors on fzf 0.60 devel)
Detect fzf version once at shell startup inside fzf_key_bindings.
Use bg-transform (non-blocking) on fzf >= 0.62 and the synchronous
transform on older builds (e.g. 0.60 devel which lacks bg-transform).
The chosen action is captured into fzf-history-widget via fish's
--inherit-variable so the check runs once, not on every Ctrl+R press.
rootiest added 1 commit 2026-05-19 00:50:55 +00:00
wrap-word in --preview-window was added alongside bg-transform.
Reuse the existing _fzf_transform_action variable (already inherited
by fzf-history-widget) to select wrap-word on newer fzf and plain
wrap on older builds — no additional version check needed.
rootiest added 1 commit 2026-05-19 00:52:48 +00:00
preview-wrap-sign is unavailable in fzf 0.60 devel. Reuse the
existing _fzf_transform_action gate to conditionally append it
to the history widget base options, keeping parity with the
wrap-word and bg-transform fallbacks.
rootiest added 1 commit 2026-05-19 00:54:13 +00:00
toggle-raw is unavailable in fzf 0.60 devel. Gate it alongside
preview-wrap-sign using the existing _fzf_transform_action check,
consolidating both version-conditional variables into one block.
rootiest merged commit a442315312 into main 2026-05-19 00:56:30 +00:00
rootiest deleted branch fix/fzf-keybind-guards 2026-05-19 00:56:30 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rootiest/fish-config#16