shell: Refactor aliases

This commit is contained in:
SebastianStork 2025-08-10 17:46:47 +02:00
parent 14b0e0ac1d
commit 9d0a734a73

View file

@ -13,35 +13,46 @@
pkgs.bat pkgs.bat
]; ];
home.shellAliases = home.shellAliases =
let let
lsAliases = lsAliases =
let let
aliasList = lib.mapCartesianProduct ({ a, b, c }: a + b + c) { a = ["ll" "lt" "l"]; b = ["" "a"]; c = ["" "d" "f"]; }; eza = [ "eza" "--header" "--group" "--time-style=long-iso" "--group-directories-first" "--sort=name" "--icons=auto" "--git" "--git-repos-no-status" "--binary" ];
eza = "eza --header --group --time-style=long-iso --group-directories-first --sort=name --icons=auto --git --git-repos-no-status --binary "; aliasPartsToCommand =
convertAliasToCmd = str: eza + (lib.replaceStrings ["ll" "lt" "l" "a" "d" "f"] ["--long " "--tree " "--oneline --dereference " "--all " "--only-dirs " "--only-files "] str); 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 in
(lib.genAttrs aliasList convertAliasToCmd) // { ls = "l"; }; { format = [ "l" "ll" "lt" ]; visibility = [ "" "a" ]; restriction = [ "" "d" "f" ]; }
|> lib.mapCartesianProduct ({ format, visibility, restriction, }: [ format visibility restriction ])
catAlias = |> lib.map (aliasParts: lib.nameValuePair (lib.concatStrings aliasParts) (aliasPartsToCommand aliasParts))
|> lib.listToAttrs;
in
lsAliases // {
ls = "l";
btm = "btm --group_processes";
cat =
let let
theme = theme =
{ {
dark = ""; dark = "";
light = "GitHub"; light = "GitHub";
} }
.${config.custom.theme}; .${config.custom.theme};
in in
{ "bat --plain --theme=${theme}";
cat = "bat --plain --theme=${theme}"; };
};
bottomAlias.btm = "btm --group_processes";
in
lib.mkMerge [
lsAliases
catAlias
bottomAlias
];
}; };
} }