Move zoxide into the shell-alias module

This commit is contained in:
SebastianStork 2025-10-07 23:55:30 +02:00
parent f649437b2f
commit c245e9422a
2 changed files with 50 additions and 48 deletions

View file

@ -8,51 +8,58 @@
options.custom.programs.shell.aliases.enable = lib.mkEnableOption "";
config = lib.mkIf config.custom.programs.shell.aliases.enable {
home.packages = [
pkgs.eza
pkgs.bat
];
programs.zoxide = {
enable = true;
options = [ "--cmd cd" ];
};
home = {
packages = [
pkgs.eza
pkgs.bat
];
home.shellAliases =
let
lsAliases =
let
eza = [ "eza" "--header" "--group" "--time-style=long-iso" "--group-directories-first" "--sort=name" "--icons=auto" "--git" "--git-repos-no-status" "--binary" ];
aliasPartsToCommand =
aliasParts:
aliasParts
|> lib.filter (aliasPart: aliasPart != "")
|> lib.map (aliasPart:
shellAliases =
let
lsAliases =
let
eza = [ "eza" "--header" "--group" "--time-style=long-iso" "--group-directories-first" "--sort=name" "--icons=auto" "--git" "--git-repos-no-status" "--binary" ];
aliasPartsToCommand =
aliasParts:
aliasParts
|> lib.filter (aliasPart: aliasPart != "")
|> lib.map (aliasPart:
{
"l" = "--oneline --dereference";
"ll" = "--long";
"lt" = "--tree";
"a" = "--all";
"d" = "--only-dirs";
"f" = "--only-files";
}
.${aliasPart})
|> (flags: eza ++ flags)
|> lib.concatStringsSep " ";
in
{ format = [ "l" "ll" "lt" ]; visibility = [ "" "a" ]; restriction = [ "" "d" "f" ]; }
|> lib.mapCartesianProduct ({ format, visibility, restriction, }: [ format visibility restriction ])
|> lib.map (aliasParts: lib.nameValuePair (lib.concatStrings aliasParts) (aliasPartsToCommand aliasParts))
|> lib.listToAttrs;
in
lsAliases // {
ls = "l";
btm = "btm --group_processes";
cat =
let
theme =
{
"l" = "--oneline --dereference";
"ll" = "--long";
"lt" = "--tree";
"a" = "--all";
"d" = "--only-dirs";
"f" = "--only-files";
dark = "";
light = "GitHub";
}
.${aliasPart})
|> (flags: eza ++ flags)
|> lib.concatStringsSep " ";
in
{ format = [ "l" "ll" "lt" ]; visibility = [ "" "a" ]; restriction = [ "" "d" "f" ]; }
|> lib.mapCartesianProduct ({ format, visibility, restriction, }: [ format visibility restriction ])
|> lib.map (aliasParts: lib.nameValuePair (lib.concatStrings aliasParts) (aliasPartsToCommand aliasParts))
|> lib.listToAttrs;
in
lsAliases // {
ls = "l";
btm = "btm --group_processes";
cat =
let
theme =
{
dark = "";
light = "GitHub";
}
.${config.custom.theme};
in
"bat --plain --theme=${theme}";
};
.${config.custom.theme};
in
"bat --plain --theme=${theme}";
};
};
};
}