nixos-configuration/modules/shells/zsh.nix
2025-03-21 02:00:29 +01:00

99 lines
2.2 KiB
Nix
Executable file

{
pkgs,
lib,
config,
...
}: {
options = {
zsh.jump = {
enable = lib.mkEnableOption "enables jump in zsh";
show-destination = lib.mkEnableOption "Echoes the folder jump changed to after jumping";
};
zsh.extraLines = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
description = "List of extra commands to run on zsh init";
};
zsh.histFile = lib.mkOption {
type = lib.types.str;
default = "$HOME/.zsh_history";
description = "Path to the zsh history file";
};
zsh.direnv = lib.mkEnableOption "Enable direnv hook";
};
config = {
programs.lsd.enable = true;
programs.zsh.enable = true;
programs.zsh.enableCompletion = true;
programs.zsh.dotDir = ".config/zsh";
programs.zsh.autosuggestion = {
enable = true;
};
programs.zsh.syntaxHighlighting = {
enable = true;
};
programs.zsh.history.path = config.zsh.histFile;
programs.zsh.shellAliases = {
ls = "lsd";
nix-rebuild = "nixos-rebuild --use-remote-sudo switch --flake /etc/nixos";
nd = "nix develop -c zsh";
};
programs.zsh.oh-my-zsh = {
enable = true;
theme = "robbyrussell";
plugins = [
"git"
"sudo"
];
};
# programs.zsh.initExtra = lib.concatStringsSep "\n" ([
# "echo zsh"
# ] ++ lib.lists.optionals config.zsh.jump.enable
# "eval");
programs.zsh.initExtra = lib.concatStringsSep "\n" (
# Add any extra lines to the zsh config
config.zsh.extraLines
++
# Add jump shell script to list if jump is enabled
(
if config.zsh.jump.show-destination
then [
"eval \"$(jump shell zsh --bind=z)\""
''
j() {
z $1;
echo $(pwd)
}
''
]
else ["eval \"$(jump shell zsh)\""]
)
++ (
if config.zsh.direnv
then ["eval \"$(direnv hook zsh)\""]
else []
)
# ++
# (
# if config.programs.nix-index.enable && config.programs.nix-index.enableZshIntegration then
# [ "source ${pkgs.nix-index}/etc/profile.d/command-not-found.sh" ]
# else
# []
# )
);
};
}