From e5c42f5d13d61b47032baad3c0b33f85c6e882f2 Mon Sep 17 00:00:00 2001 From: alexion Date: Sat, 18 Jul 2026 19:10:05 -0400 Subject: [PATCH] Merge the fish config fragments back into one config.fish The interactive init is small; four fragment files was over-splitting it. Keep the mechanic (a real fish file inlined by Nix into config.fish) but merge the fragments into a single modules/fish/config.fish read with builtins.readFile. Rendered config is unchanged. --- .claude/tasks/0005-fish-shell-module.md | 2 +- modules/fish/config.fish | 23 +++++++++++++++++++++++ modules/fish/config/bindings.fish | 2 -- modules/fish/config/done.fish | 3 --- modules/fish/config/env.fish | 6 ------ modules/fish/config/path.fish | 9 --------- modules/fish/fish.nix | 12 +++--------- 7 files changed, 27 insertions(+), 30 deletions(-) create mode 100644 modules/fish/config.fish delete mode 100644 modules/fish/config/bindings.fish delete mode 100644 modules/fish/config/done.fish delete mode 100644 modules/fish/config/env.fish delete mode 100644 modules/fish/config/path.fish diff --git a/.claude/tasks/0005-fish-shell-module.md b/.claude/tasks/0005-fish-shell-module.md index 1795690..ff7654d 100644 --- a/.claude/tasks/0005-fish-shell-module.md +++ b/.claude/tasks/0005-fish-shell-module.md @@ -39,6 +39,6 @@ Configure the plugins natively through home-manager rather than a fish plugin ma - **Abbreviation-first.** Every non-eza alias is now a `shellAbbr` (the eza `ls` family stays an alias), `preferAbbrs = true`, and `generateCompletions = true` is pinned rather than left to the upstream default. - **vi command-line editing.** `interactiveShellInit` sets `fish_key_bindings fish_vi_key_bindings`; the `bang-bang` plugin re-binds `!`/`$` in insert mode via its own `--on-variable fish_key_bindings` handler, so the switch keeps them working. - **Trimmed aliases.** Navigation capped at four dots (`.....`/`......` dropped); `psmem`, `psmem10`, `dir`, `vdir`, and `please` removed. -- **Interactive init is split in the repo, assembled by Nix.** The Module lives at `modules/fish/fish.nix`. Its `interactiveShellInit` is concatenated (in order) from concern-scoped fragments under `modules/fish/config/` — `bindings.fish` (vi editing), `env.fish` (`EDITOR`/`VISUAL` and the bat manpager), `done.fish` (the done plugin tuning), and `path.fish` (`~/.local/bin` and `~/.fish_profile`) — via `lib.concatMapStringsSep "\n" builtins.readFile`. Each concern stays an editable fish file, but home-manager still writes one `~/.config/fish/config.fish`; nothing of ours is autoloaded from a separate runtime file. The concatenated result is byte-identical to the previous monolithic `config.fish` (same toplevel hash). +- **Interactive init lives in a real fish file.** The Module lives at `modules/fish/fish.nix`; its `interactiveShellInit` is `builtins.readFile ./config.fish`, so the interactive init is written as one editable fish file (vi editing, `EDITOR`/`VISUAL`, the bat manpager, the done plugin tuning, and `~/.local/bin`/`~/.fish_profile`) that home-manager renders into `~/.config/fish/config.fish`. The file is small enough that splitting it into fragments was not worth the indirection; Nix inlines it at build time, so nothing of ours is autoloaded from a separate runtime file. - **`copy` stays a function file.** `functions/copy.fish` holds the non-trivial `copy` body, read into the `functions` option; fish autoloads function files lazily, so that is the idiomatic home for a function. Trivial one-liner functions stay inline in `fish.nix`. - The Auto-loader only collects `.nix`, so every `.fish` file under `modules/fish/` is inert to it. diff --git a/modules/fish/config.fish b/modules/fish/config.fish new file mode 100644 index 0000000..08d8b9e --- /dev/null +++ b/modules/fish/config.fish @@ -0,0 +1,23 @@ +# vi-style modal editing on the command line. +set -g fish_key_bindings fish_vi_key_bindings + +set -gx EDITOR nvim +set -gx VISUAL nvim + +# Render man pages through bat. +set -x MANROFFOPT "-c" +set -x MANPAGER "sh -c 'col -bx | bat -l man -p'" + +# Tune the done plugin: only notify for commands past 10s, at low urgency. +set -g __done_min_cmd_duration 10000 +set -g __done_notification_urgency_level low + +# Prepend ~/.local/bin to PATH when it exists. +if test -d ~/.local/bin + fish_add_path ~/.local/bin +end + +# Apply fish-compatible profile overrides if present. +if test -f ~/.fish_profile + source ~/.fish_profile +end diff --git a/modules/fish/config/bindings.fish b/modules/fish/config/bindings.fish deleted file mode 100644 index 7d12cf0..0000000 --- a/modules/fish/config/bindings.fish +++ /dev/null @@ -1,2 +0,0 @@ -# vi-style modal editing on the command line. -set -g fish_key_bindings fish_vi_key_bindings diff --git a/modules/fish/config/done.fish b/modules/fish/config/done.fish deleted file mode 100644 index ff0e81e..0000000 --- a/modules/fish/config/done.fish +++ /dev/null @@ -1,3 +0,0 @@ -# Tune the done plugin: only notify for commands past 10s, at low urgency. -set -g __done_min_cmd_duration 10000 -set -g __done_notification_urgency_level low diff --git a/modules/fish/config/env.fish b/modules/fish/config/env.fish deleted file mode 100644 index 4a3ed44..0000000 --- a/modules/fish/config/env.fish +++ /dev/null @@ -1,6 +0,0 @@ -set -gx EDITOR nvim -set -gx VISUAL nvim - -# Render man pages through bat. -set -x MANROFFOPT "-c" -set -x MANPAGER "sh -c 'col -bx | bat -l man -p'" diff --git a/modules/fish/config/path.fish b/modules/fish/config/path.fish deleted file mode 100644 index 9063e70..0000000 --- a/modules/fish/config/path.fish +++ /dev/null @@ -1,9 +0,0 @@ -# Prepend ~/.local/bin to PATH when it exists. -if test -d ~/.local/bin - fish_add_path ~/.local/bin -end - -# Apply fish-compatible profile overrides if present. -if test -f ~/.fish_profile - source ~/.fish_profile -end diff --git a/modules/fish/fish.nix b/modules/fish/fish.nix index e040ba0..b061318 100644 --- a/modules/fish/fish.nix +++ b/modules/fish/fish.nix @@ -115,15 +115,9 @@ in }; }; - # config.fish is assembled here, in order, from the fragments under - # ./config so each concern stays an editable fish file while - # home-manager still writes a single ~/.config/fish/config.fish. - interactiveShellInit = lib.concatMapStringsSep "\n" builtins.readFile [ - ./config/bindings.fish - ./config/env.fish - ./config/done.fish - ./config/path.fish - ]; + # Read from a real fish file, which home-manager renders into + # ~/.config/fish/config.fish. + interactiveShellInit = builtins.readFile ./config.fish; }; }; };