From 56cd6332aebc8a7c1ffc0080ed0277903b12d6a0 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Sun, 25 May 2025 22:41:23 +0200 Subject: [PATCH] feat(shell): better shell options, move tmux to shell --- users/modules/default.nix | 1 - users/modules/shell/bash.nix | 1 + users/modules/shell/default.nix | 9 ++++++--- users/modules/shell/fish.nix | 18 +++++++++++++----- users/modules/{ => shell}/tmux.nix | 15 ++++++++++++--- users/modules/shell/zsh.nix | 30 +++++++++++++++++------------- users/phundrak/light-home.nix | 5 ++++- 7 files changed, 53 insertions(+), 26 deletions(-) rename users/modules/{ => shell}/tmux.nix (93%) diff --git a/users/modules/default.nix b/users/modules/default.nix index a1696e2..985a5ed 100644 --- a/users/modules/default.nix +++ b/users/modules/default.nix @@ -12,7 +12,6 @@ ./shell ./ssh.nix ./tealdeer.nix - ./tmux.nix ./vcs ]; } diff --git a/users/modules/shell/bash.nix b/users/modules/shell/bash.nix index bdc8a59..241ec8e 100644 --- a/users/modules/shell/bash.nix +++ b/users/modules/shell/bash.nix @@ -25,6 +25,7 @@ in { config = lib.mkIf cfg.enable { programs.bash = { enable = true; + inherit (cfg) bashrcExtra; shellAliases = cfg.aliases; shellOptions = [ "histappend" diff --git a/users/modules/shell/default.nix b/users/modules/shell/default.nix index 9663f91..a97c931 100644 --- a/users/modules/shell/default.nix +++ b/users/modules/shell/default.nix @@ -67,24 +67,26 @@ in { ./bash.nix ./fish.nix ./starship.nix + ./tmux.nix ./zsh.nix ]; options.modules.shell = { + tmux.enable = mkEnableOption "Enables tmux"; enableBash = mkOption { type = types.bool; default = true; - description = "enables bash"; + description = "Enables bash"; }; enableFish = mkOption { type = types.bool; default = true; - description = "enables fish"; + description = "Enables fish"; }; enableZsh = mkOption { type = types.bool; default = true; - description = "enables zsh"; + description = "Enables zsh"; }; starship = { enable = mkEnableOption "Enables the starship prompt."; @@ -124,6 +126,7 @@ in { enable = mkDefault cfg.enableZsh; abbrs = mkDefault aliases; }; + tmux.enable = cfg.tmux.enable; inherit (cfg) starship; }; diff --git a/users/modules/shell/fish.nix b/users/modules/shell/fish.nix index 84854a4..21603a1 100644 --- a/users/modules/shell/fish.nix +++ b/users/modules/shell/fish.nix @@ -17,6 +17,10 @@ in { lns = "ln -si"; }; }; + extraShellInit = mkOption { + type = types.lines; + default = ""; + }; }; config = lib.mkIf cfg.enable { @@ -24,11 +28,15 @@ in { enable = true; shellAbbrs = cfg.abbrs; preferAbbrs = true; - shellInit = '' - function fish_command_not_found - __fish_default_command_not_found_handler $argv - end - ''; + shellInit = with lib; + concatLines [ + '' + function fish_command_not_found + __fish_default_command_not_found_handler $argv + end + '' + cfg.extraShellInit + ]; plugins = [ { name = "bass"; diff --git a/users/modules/tmux.nix b/users/modules/shell/tmux.nix similarity index 93% rename from users/modules/tmux.nix rename to users/modules/shell/tmux.nix index acc2262..0eea1d1 100644 --- a/users/modules/tmux.nix +++ b/users/modules/shell/tmux.nix @@ -1,6 +1,15 @@ -{pkgs, ...}: { - programs.tmux = { - enable = true; +{ + pkgs, + lib, + config, + ... +}: +with lib; let + cfg = config.modules.tmux; +in { + options.modules.tmux.enable = mkEnableOption "Enable tmux"; + config.programs.tmux = mkIf cfg.enable { + inherit (cfg) enable; baseIndex = 1; clock24 = true; customPaneNavigationAndResize = true; diff --git a/users/modules/shell/zsh.nix b/users/modules/shell/zsh.nix index f9561a5..0fd6021 100644 --- a/users/modules/shell/zsh.nix +++ b/users/modules/shell/zsh.nix @@ -8,7 +8,7 @@ with lib; let cfg = config.modules.zsh; in { options.modules.zsh = { - enable = lib.mkEnableOption "enables zsh"; + enable = lib.mkEnableOption "Enables zsh"; abbrs = lib.mkOption { type = types.attrsOf types.str; default = {}; @@ -19,17 +19,7 @@ in { }; zshrcExtra = lib.mkOption { type = types.lines; - default = '' - bindkey -e - bindkey '^p' history-search-backward - bindkey '^n' history-search-forward - - # Completion styling - zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' - zstyle ':completion:*' list-colors "''${(s.:.)LS_COLORS}" - zstyle ':completion:*' menu no - zstyle ':fzf-tab:complete:cd:*' fzf-preview '${pkgs.eza}/bin/eza $realpath' - ''; + default = ""; }; }; @@ -50,7 +40,21 @@ in { saveNoDups = true; }; historySubstringSearch.enable = true; - initContent = cfg.zshrcExtra; + initContent = with lib; + concatLines [ + '' + bindkey -e + bindkey '^p' history-search-backward + bindkey '^n' history-search-forward + + # Completion styling + zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' + zstyle ':completion:*' list-colors "''${(s.:.)LS_COLORS}" + zstyle ':completion:*' menu no + zstyle ':fzf-tab:complete:cd:*' fzf-preview '${pkgs.eza}/bin/eza $realpath' + '' + cfg.zshrcExtra + ]; oh-my-zsh = { enable = true; plugins = [ diff --git a/users/phundrak/light-home.nix b/users/phundrak/light-home.nix index ccba29c..8a6dff1 100644 --- a/users/phundrak/light-home.nix +++ b/users/phundrak/light-home.nix @@ -51,7 +51,10 @@ in { }; modules = { - shell.starship.enable = true; + shell = { + starship.enable = true; + tmux.enable = true; + }; vcs = { git.enable = true; jj.enable = true;