niksos/modules/cli/zsh.nix

106 lines
3.5 KiB
Nix
Raw Normal View History

2023-09-08 16:10:15 +02:00
{
config,
2023-10-13 21:04:24 +02:00
lib,
2023-09-08 16:10:15 +02:00
pkgs,
...
2024-05-05 12:38:40 +02:00
}: let
2024-07-15 23:18:25 +02:00
cfg = config.poz.programs.zsh;
inherit (config.poz.other.system) username;
2024-05-05 12:38:40 +02:00
2024-07-25 11:45:44 +02:00
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption mkOption;
2024-05-05 12:38:40 +02:00
inherit (lib.types) attrs bool;
2023-10-13 21:04:24 +02:00
in {
2024-07-15 23:18:25 +02:00
options.poz.programs.zsh = {
2024-04-05 22:59:32 +02:00
enable = mkEnableOption "zsh";
2023-11-25 17:12:09 +01:00
extraAliases = mkOption {
2024-05-05 12:38:40 +02:00
type = attrs;
2023-11-25 17:12:09 +01:00
description = "extra shell aliases";
default = {};
};
profiling = mkOption {
2024-05-05 12:38:40 +02:00
type = bool;
2023-11-25 17:12:09 +01:00
description = "enable zsh profiling";
default = false;
};
};
2023-10-13 21:04:24 +02:00
config = mkIf cfg.enable {
2024-02-14 15:38:28 +01:00
programs.zsh.enable = true;
users.users.${username}.shell = pkgs.zsh;
2024-02-14 15:38:28 +01:00
environment = {
shells = [ pkgs.zsh ];
pathsToLink = [ "/share/zsh" ];
};
home-manager.users.${username} = {
2024-05-17 00:10:31 +02:00
# for fzf-tab
home.packages = [ pkgs.fzf ];
2024-05-17 00:09:37 +02:00
programs.zsh = {
enable = true;
shellAliases = {
cl = "clear";
cp = "cp -ivr";
mv = "mv -iv";
rm = "trash -v";
l = "eza --icons -a";
e = "eza --icons -lha --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";
n = "nix";
woman = "man";
open = "xdg-open";
":q" = "exit";
emacs = ":(){ :|:& };:";
m = "make";
2024-06-05 12:32:35 +02:00
sys = "systemctl";
2024-05-17 00:09:37 +02:00
} // 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;
};
autosuggestion.enable = true;
enableCompletion = true;
autocd = false;
dotDir = ".config/zsh";
plugins = [
{
2024-06-07 21:19:52 +02:00
name = "zsh-fast-syntax-highlighting";
file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
src = pkgs.zsh-fast-syntax-highlighting;
2024-05-17 00:09:37 +02:00
}
{
name = "zsh-nix-shell";
2024-06-07 21:19:52 +02:00
file = "share/zsh-nix-shell/nix-shell.plugin.zsh";
src = pkgs.zsh-nix-shell;
2024-05-17 00:09:37 +02:00
}
2024-05-17 00:10:31 +02:00
{
2024-06-07 21:19:52 +02:00
name = "zsh-fzf-tab";
file = "share/fzf-tab/fzf-tab.plugin.zsh";
src = pkgs.zsh-fzf-tab;
}
{
name = "zsh-vi-mode";
file = "share/zsh-vi-mode/zsh-vi-mode.plugin.sh";
src = pkgs.zsh-vi-mode;
2024-05-17 00:10:31 +02:00
}
2024-05-17 00:09:37 +02:00
];
};
2023-09-08 16:10:15 +02:00
};
};
}