From 9eb0fe797a3430d81b6b79693d830c9face0ef9c Mon Sep 17 00:00:00 2001 From: alexion Date: Sat, 18 Jul 2026 18:17:48 -0400 Subject: [PATCH] feat(fish): gate the default shell and prefer abbreviations Move the login-shell switch behind a new modules.fish.defaultShell option (default false; neogaia opts in). Convert every non-eza alias to an abbreviation, set preferAbbrs and pin generateCompletions, and switch the command line to vi-style editing. Cap navigation at four dots and drop psmem/psmem10/dir/vdir/please. Comment the installed packages. --- .claude/tasks/0005-fish-shell-module.md | 7 ++++ hosts/neogaia/default.nix | 1 + modules/fish.nix | 50 ++++++++++++++++--------- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/.claude/tasks/0005-fish-shell-module.md b/.claude/tasks/0005-fish-shell-module.md index 7c0ce56..4492e09 100644 --- a/.claude/tasks/0005-fish-shell-module.md +++ b/.claude/tasks/0005-fish-shell-module.md @@ -32,3 +32,10 @@ Configure the plugins natively through home-manager rather than a fish plugin ma - **`copy` kept verbatim** (including the upstream `trim-right` call) to preserve exact parity with the current shell. - **Verification.** The `neogaia` system toplevel builds (the spec's primary seam). The rendered `~/.config/fish/` was inspected in the build output: aliases, the three helper functions, the `fastfetch` greeting, the bat manpager, the `done` tuning vars, and the `conf.d/plugin-done.fish` + `conf.d/plugin-bang-bang.fish` plugin files are all present; `users.users.alexion.shell` resolves to `pkgs.fish`. + +### Post-review adjustments + +- **`defaultShell` option.** Setting fish as the login shell moved behind `modules.fish.defaultShell` (default `false`, gated with `mkIf`); `neogaia` opts in explicitly. Enabling the Module alone no longer changes the login shell. +- **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. diff --git a/hosts/neogaia/default.nix b/hosts/neogaia/default.nix index 49f8925..3e5a605 100644 --- a/hosts/neogaia/default.nix +++ b/hosts/neogaia/default.nix @@ -37,6 +37,7 @@ # fish as the login shell. modules.fish.enable = true; + modules.fish.defaultShell = true; # Locale preferences for the base system. time.timeZone = "America/New_York"; diff --git a/modules/fish.nix b/modules/fish.nix index a1ac01d..f651254 100644 --- a/modules/fish.nix +++ b/modules/fish.nix @@ -4,34 +4,50 @@ pkgs, ... }: -# fish for the primary user, configured natively through home-manager and set -# as their default login shell. Wires the done and bang-bang plugins, a -# fastfetch greeting, a bat-backed manpager, helper functions, and the eza and -# navigation aliases. +# fish for the primary user, configured natively through home-manager. Wires the +# done and bang-bang plugins, a fastfetch greeting, a bat-backed manpager, helper +# functions, the eza aliases, and vi-style command-line editing. Set fish as the +# default login shell by also turning on `modules.fish.defaultShell`. let cfg = config.modules.fish; user = config.user.name; in { - options.modules.fish.enable = lib.mkEnableOption "fish as the user's shell, configured via home-manager"; + options.modules.fish = { + enable = lib.mkEnableOption "fish as the user's shell, configured via home-manager"; + + defaultShell = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Set fish as the user's default login shell."; + }; + }; config = lib.mkIf cfg.enable { # System-level fish: registers it in /etc/shells and installs vendor # completions. programs.fish.enable = true; - users.users.${user}.shell = pkgs.fish; + users.users.${user}.shell = lib.mkIf cfg.defaultShell pkgs.fish; home-manager.users.${user} = { home.packages = with pkgs; [ - eza - bat - fastfetch - wget + eza # modern ls with git awareness and icons; backs the ls aliases + bat # syntax-highlighting cat/pager; backs the manpager below + fastfetch # system-info banner printed as the shell greeting + wget # non-interactive HTTP downloader; backs the wget abbreviation ]; programs.fish = { enable = true; + # Relied-on upstream defaults, pinned so a future change can't silently + # alter behaviour. + generateCompletions = true; + + # Prefer abbreviations over aliases when other modules wire up fish + # shortcuts, matching the abbreviation-first style below. + preferAbbrs = true; + # done notifies when a long command finishes; bang-bang restores the !! # and !$ history bindings. plugins = [ @@ -45,20 +61,20 @@ in } ]; + # Only the eza listings stay aliases; everything else is an abbreviation. shellAliases = { - # Replace ls with eza. ls = "eza -al --color=always --group-directories-first --icons"; la = "eza -a --color=always --group-directories-first --icons"; ll = "eza -l --color=always --group-directories-first --icons"; lt = "eza -aT --color=always --group-directories-first --icons"; "l." = "eza -a | grep -e '^\\.'"; + }; + shellAbbrs = { # Walk up the tree. ".." = "cd .."; "..." = "cd ../.."; "...." = "cd ../../.."; - "....." = "cd ../../../.."; - "......" = "cd ../../../../.."; vi = "nvim"; vim = "nvim"; @@ -68,15 +84,10 @@ in tarnow = "tar -acf "; untar = "tar -zxvf "; wget = "wget -c "; - psmem = "ps auxf | sort -nr -k 4"; - psmem10 = "ps auxf | sort -nr -k 4 | head -10"; - dir = "dir --color=auto"; - vdir = "vdir --color=auto"; grep = "grep --color=auto"; fgrep = "fgrep --color=auto"; egrep = "egrep --color=auto"; jctl = "journalctl -p 3 -xb"; - please = "sudo"; # Rebuild the system, and reclaim disk from old generations. update = "sudo nixos-rebuild switch"; @@ -114,6 +125,9 @@ in }; interactiveShellInit = '' + # 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