niksos/modules/cli/zsh.nix

115 lines
4.1 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
2023-10-13 21:04:24 +02:00
cfg = config.myOptions.programs.zsh;
2024-04-14 18:49:29 +02:00
inherit (config.myOptions.other.system) username;
2024-05-05 12:38:40 +02:00
inherit (lib) mkEnableOption mkIf mkOption;
inherit (lib.types) attrs bool;
2023-10-13 21:04:24 +02:00
in {
2023-11-25 17:12:09 +01:00
options.myOptions.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";
s = "sudo";
} // 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 = [
{
name = "fast-syntax-highlighting";
file = "fast-syntax-highlighting.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "zdharma-continuum";
repo = "fast-syntax-highlighting";
rev = "cf318e06a9b7c9f2219d78f41b46fa6e06011fd9";
hash = "sha256-RVX9ZSzjBW3LpFs2W86lKI6vtcvDWP6EPxzeTcRZua4=";
};
}
{
name = "zsh-nix-shell";
file = "nix-shell.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "chisui";
repo = "zsh-nix-shell";
rev = "v0.8.0";
hash = "sha256-Z6EYQdasvpl1P78poj9efnnLj7QQg13Me8x1Ryyw+dM=";
};
}
2024-05-17 00:10:31 +02:00
{
name = "fzf-tab";
file = "fzf-tab.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "Aloxaf";
repo = "fzf-tab";
rev = "c7fb028ec0bbc1056c51508602dbd61b0f475ac3";
hash = "sha256-Qv8zAiMtrr67CbLRrFjGaPzFZcOiMVEFLg1Z+N6VMhg=";
};
}
2024-05-17 00:09:37 +02:00
];
};
2023-09-08 16:10:15 +02:00
};
};
}