feat(edit): multi-editor launcher with GUI/terminal fallbacks #59

Merged
rootiest merged 3 commits from feat-edit-multi-editor-launcher into main 2026-06-19 05:58:21 +00:00
Owner

Summary

Rewrites functions/edit.fish (previously a thin nvim wrapper) into a flexible launcher that picks a GUI or terminal editor, resolves rich fallback chains, and can open the clipboard or a literal string as throwaway files. Drives both interactive CLI use (edit notes.txt, abbreviated e) and desktop shortcuts (edit --clipboard --visual).

Behavior

  • Mode: --visual/--terminal force GUI/terminal; with neither, mode auto-detects — interactive tty → terminal ($EDITOR), detached (e.g. .desktop launch) → GUI ($VISUAL).
  • GUI fallback chain: zed → antigravity-ide → code → kate → kwrite → gnome-text-editor → gedit
  • Terminal fallback chain: nvim → vim → micro → nano → vi
  • --editor=X overrides resolution with a specific binary.
  • --clipboard reuses the existing p function (p > tmpfile); --text=STR writes a literal string to a temp file. Both are additive with positional files.
  • --new maps to per-editor new-window flags (kate/kwrite --new, code/codium/zed -n, gnome-text-editor --new-window); ignored where unsupported (best-effort).
  • --verbose prints the launch command and lets editor output through; --silent suppresses everything. The two, and --visual/--terminal, are mutually exclusive (clear errors).
  • GUI editors launch detached (&; disown, output to /dev/null); terminal editors run in the foreground.

Opinionated guard (C1)

Gated in-body via __fish_config_op_enabled __fish_config_op_aliases (live toggle). When C1 is disabled it falls back to the legacy bare-editor behavior ($EDITOR → nvim → nano → vi), so it stays a drop-in for the old edit.

Docs

  • docs/fish-config.md: rewrote the edit function entry and added an edit row to the C1 Component Reference table.
  • README.md + AGENTS C1 shadow list: added edit→multi-editor launcher.
  • Generated outputs (docs/fish-config.1, docs/html/, docs/wiki/) regenerate via the Gitea Actions man-page/docs workflow on merge to main.

Notes

  • Clipboard/text temp files are left for the OS to reap from /tmp — GUI editors are detached, so they can't be safely removed mid-edit.
  • No edt alias added: the existing abbr -a e edit already provides a short name and now points at the new launcher.

Manual Verification

  • edit notes.txt in an interactive terminal opens it in the terminal editor ($EDITOR/nvim).
  • edit --visual notes.txt opens it in the GUI editor (kate/zed/etc.).
  • edit --editor=code README.md opens in VS Code specifically.
  • edit --clipboard opens current clipboard contents as a temp file.
  • edit --text="hello world" opens a temp file containing hello world.
  • edit --terminal --new todo.md opens a new window/instance where supported.
  • edit --visual --terminal and edit -v -s each error out with a clear message and exit 1.
  • edit -e nonexistent-binary file errors with "editor not found" and exit 1.
  • edit -h shows colored help on stdout.
  • With set -U __fish_config_op_aliases off, edit file falls back to the bare editor (no GUI/clipboard frills); re-enabling restores the launcher live.
## Summary Rewrites `functions/edit.fish` (previously a thin nvim wrapper) into a flexible launcher that picks a **GUI or terminal** editor, resolves rich fallback chains, and can open the clipboard or a literal string as throwaway files. Drives both interactive CLI use (`edit notes.txt`, abbreviated `e`) and desktop shortcuts (`edit --clipboard --visual`). ## Behavior - **Mode:** `--visual`/`--terminal` force GUI/terminal; with neither, mode auto-detects — interactive tty → terminal (`$EDITOR`), detached (e.g. `.desktop` launch) → GUI (`$VISUAL`). - **GUI fallback chain:** `zed → antigravity-ide → code → kate → kwrite → gnome-text-editor → gedit` - **Terminal fallback chain:** `nvim → vim → micro → nano → vi` - `--editor=X` overrides resolution with a specific binary. - `--clipboard` reuses the existing `p` function (`p > tmpfile`); `--text=STR` writes a literal string to a temp file. Both are additive with positional files. - `--new` maps to per-editor new-window flags (kate/kwrite `--new`, code/codium/zed `-n`, gnome-text-editor `--new-window`); ignored where unsupported (best-effort). - `--verbose` prints the launch command and lets editor output through; `--silent` suppresses everything. The two, and `--visual`/`--terminal`, are mutually exclusive (clear errors). - GUI editors launch detached (`&; disown`, output to `/dev/null`); terminal editors run in the foreground. ## Opinionated guard (C1) Gated in-body via `__fish_config_op_enabled __fish_config_op_aliases` (live toggle). When C1 is disabled it falls back to the legacy bare-editor behavior (`$EDITOR` → nvim → nano → vi), so it stays a drop-in for the old `edit`. ## Docs - `docs/fish-config.md`: rewrote the `edit` function entry and added an `edit` row to the C1 Component Reference table. - `README.md` + AGENTS C1 shadow list: added `edit`→multi-editor launcher. - Generated outputs (`docs/fish-config.1`, `docs/html/`, `docs/wiki/`) regenerate via the Gitea Actions man-page/docs workflow on merge to `main`. ## Notes - Clipboard/text temp files are left for the OS to reap from `/tmp` — GUI editors are detached, so they can't be safely removed mid-edit. - No `edt` alias added: the existing `abbr -a e edit` already provides a short name and now points at the new launcher. ## Manual Verification - [x] `edit notes.txt` in an interactive terminal opens it in the terminal editor (`$EDITOR`/nvim). - [x] `edit --visual notes.txt` opens it in the GUI editor (kate/zed/etc.). - [x] `edit --editor=code README.md` opens in VS Code specifically. - [x] `edit --clipboard` opens current clipboard contents as a temp file. - [x] `edit --text="hello world"` opens a temp file containing `hello world`. - [x] `edit --terminal --new todo.md` opens a new window/instance where supported. - [x] `edit --visual --terminal` and `edit -v -s` each error out with a clear message and exit 1. - [x] `edit -e nonexistent-binary file` errors with "editor not found" and exit 1. - [x] `edit -h` shows colored help on stdout. - [x] With `set -U __fish_config_op_aliases off`, `edit file` falls back to the bare editor (no GUI/clipboard frills); re-enabling restores the launcher live.
rootiest added 1 commit 2026-06-19 04:59:49 +00:00
Rewrite functions/edit.fish as a flexible launcher supporting GUI and
terminal editors with rich fallback chains, clipboard/text temp files,
new-window flags, and verbose/silent output control.

- --visual/--terminal force mode; default auto-detects via tty
- GUI chain: zed → antigravity-ide → code → kate → kwrite → gnome-text-editor → gedit
- Terminal chain: nvim → vim → micro → nano → vi
- --clipboard reuses the existing p function; --text opens a literal string
- --new maps to per-editor new-window flags (best-effort)
- C1 guard falls back to legacy bare-editor behavior when disabled

Docs: update fish-config.md function entry + C1 table, README and AGENTS C1 shadow lists.
rootiest added 1 commit 2026-06-19 05:54:20 +00:00
rootiest added 1 commit 2026-06-19 05:57:03 +00:00
VISUAL was hardwired to $EDITOR (nvim), so 'edit --visual' would launch a
terminal editor detached with no tty. Comment it out so --visual falls
through to the GUI fallback chain, and let users set a real GUI editor via
local.fish. Update the editor-variable docs to match.
rootiest merged commit 1433844c2b into main 2026-06-19 05:58:21 +00:00
rootiest deleted branch feat-edit-multi-editor-launcher 2026-06-19 05:58:21 +00:00
Sign in to join this conversation.