niksos/modules/cli/zsh.nix

98 lines
3.6 KiB
Nix

{
config,
lib,
pkgs,
...
}: with lib; let
cfg = config.myOptions.programs.zsh;
username = config.myOptions.other.system.username;
in {
options.myOptions.programs.zsh = {
enable = mkEnableOption "enable zsh";
extraAliases = mkOption {
type = types.attrs;
description = "extra shell aliases";
default = {};
};
profiling = mkOption {
type = types.bool;
description = "enable zsh profiling";
default = false;
};
};
config = mkIf cfg.enable {
programs.zsh.enable = true;
users.users.${username}.shell = pkgs.zsh;
environment = {
shells = [ pkgs.zsh ];
pathsToLink = [ "/share/zsh" ];
};
home-manager.users.${username} = {
programs.zsh = {
enable = true;
shellAliases = {
cl = "clear";
cp = "cp -ivr";
mv = "mv -iv";
rm = "trash -v";
l = "eza -a --icons";
e = "eza -lha --icons --git";
untar = "tar -xvf";
untargz = "tar -xzf";
mnt = "udisksctl mount -b";
umnt = "udisksctl unmount -b";
v = "nvim";
kys = "shutdown now";
gpl = "curl https://www.gnu.org/licenses/gpl-3.0.txt -o LICENSE";
agpl = "curl https://www.gnu.org/licenses/agpl-3.0.txt -o LICENSE";
g = "git";
gs = "g stash";
n = "nix";
woman = "man";
open = "xdg-open";
":q" = "exit";
emacs = ":(){ :|:& };:";
} // cfg.extraAliases;
initExtraFirst = mkIf cfg.profiling "zmodload zsh/zprof";
initExtra = mkIf cfg.profiling "zprof";
history = {
path = "${config.home-manager.users.${username}.xdg.dataHome}/zsh/zsh_history";
size = 9999999999;
save = 9999999999;
extended = true;
ignoreSpace = true;
};
enableAutosuggestions = true;
enableCompletion = true;
autocd = false;
dotDir = ".config/zsh";
plugins = [
{
name = "fast-syntax-highlighting";
file = "fast-syntax-highlighting.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "zdharma-continuum";
repo = "fast-syntax-highlighting";
rev = "cf318e06a9b7c9f2219d78f41b46fa6e06011fd9";
sha256 = "sha256-RVX9ZSzjBW3LpFs2W86lKI6vtcvDWP6EPxzeTcRZua4=";
};
}
{
name = "zsh-nix-shell";
file = "nix-shell.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "chisui";
repo = "zsh-nix-shell";
rev = "v0.7.0";
sha256 = "0za4aiwwrlawnia4f29msk822rj9bgcygw6a8a6iikiwzjjz0g91";
};
}
];
};
};
};
}