feat(shell): better shell options, move tmux to shell

This commit is contained in:
Lucien Cartier-Tilet 2025-05-25 22:41:23 +02:00
parent f13a0f6863
commit 56cd6332ae
Signed by: phundrak
SSH Key Fingerprint: SHA256:CE0HPsbW3L2YiJETx1zYZ2muMptaAqTN2g3498KrMkc
7 changed files with 53 additions and 26 deletions

View File

@ -12,7 +12,6 @@
./shell ./shell
./ssh.nix ./ssh.nix
./tealdeer.nix ./tealdeer.nix
./tmux.nix
./vcs ./vcs
]; ];
} }

View File

@ -25,6 +25,7 @@ in {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.bash = { programs.bash = {
enable = true; enable = true;
inherit (cfg) bashrcExtra;
shellAliases = cfg.aliases; shellAliases = cfg.aliases;
shellOptions = [ shellOptions = [
"histappend" "histappend"

View File

@ -67,24 +67,26 @@ in {
./bash.nix ./bash.nix
./fish.nix ./fish.nix
./starship.nix ./starship.nix
./tmux.nix
./zsh.nix ./zsh.nix
]; ];
options.modules.shell = { options.modules.shell = {
tmux.enable = mkEnableOption "Enables tmux";
enableBash = mkOption { enableBash = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
description = "enables bash"; description = "Enables bash";
}; };
enableFish = mkOption { enableFish = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
description = "enables fish"; description = "Enables fish";
}; };
enableZsh = mkOption { enableZsh = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
description = "enables zsh"; description = "Enables zsh";
}; };
starship = { starship = {
enable = mkEnableOption "Enables the starship prompt."; enable = mkEnableOption "Enables the starship prompt.";
@ -124,6 +126,7 @@ in {
enable = mkDefault cfg.enableZsh; enable = mkDefault cfg.enableZsh;
abbrs = mkDefault aliases; abbrs = mkDefault aliases;
}; };
tmux.enable = cfg.tmux.enable;
inherit (cfg) starship; inherit (cfg) starship;
}; };

View File

@ -17,6 +17,10 @@ in {
lns = "ln -si"; lns = "ln -si";
}; };
}; };
extraShellInit = mkOption {
type = types.lines;
default = "";
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@ -24,11 +28,15 @@ in {
enable = true; enable = true;
shellAbbrs = cfg.abbrs; shellAbbrs = cfg.abbrs;
preferAbbrs = true; preferAbbrs = true;
shellInit = '' shellInit = with lib;
function fish_command_not_found concatLines [
__fish_default_command_not_found_handler $argv ''
end function fish_command_not_found
''; __fish_default_command_not_found_handler $argv
end
''
cfg.extraShellInit
];
plugins = [ plugins = [
{ {
name = "bass"; name = "bass";

View File

@ -1,6 +1,15 @@
{pkgs, ...}: { {
programs.tmux = { pkgs,
enable = true; 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; baseIndex = 1;
clock24 = true; clock24 = true;
customPaneNavigationAndResize = true; customPaneNavigationAndResize = true;

View File

@ -8,7 +8,7 @@ with lib; let
cfg = config.modules.zsh; cfg = config.modules.zsh;
in { in {
options.modules.zsh = { options.modules.zsh = {
enable = lib.mkEnableOption "enables zsh"; enable = lib.mkEnableOption "Enables zsh";
abbrs = lib.mkOption { abbrs = lib.mkOption {
type = types.attrsOf types.str; type = types.attrsOf types.str;
default = {}; default = {};
@ -19,17 +19,7 @@ in {
}; };
zshrcExtra = lib.mkOption { zshrcExtra = lib.mkOption {
type = types.lines; type = types.lines;
default = '' 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'
'';
}; };
}; };
@ -50,7 +40,21 @@ in {
saveNoDups = true; saveNoDups = true;
}; };
historySubstringSearch.enable = 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 = { oh-my-zsh = {
enable = true; enable = true;
plugins = [ plugins = [

View File

@ -51,7 +51,10 @@ in {
}; };
modules = { modules = {
shell.starship.enable = true; shell = {
starship.enable = true;
tmux.enable = true;
};
vcs = { vcs = {
git.enable = true; git.enable = true;
jj.enable = true; jj.enable = true;