shell: Refactor aliases

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

View file

@ -17,13 +17,33 @@
let
lsAliases =
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 ";
convertAliasToCmd = str: eza + (lib.replaceStrings ["ll" "lt" "l" "a" "d" "f"] ["--long " "--tree " "--oneline --dereference " "--all " "--only-dirs " "--only-files "] str);
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
(lib.genAttrs aliasList convertAliasToCmd) // { ls = "l"; };
catAlias =
{ 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 =
{
@ -32,16 +52,7 @@
}
.${config.custom.theme};
in
{
cat = "bat --plain --theme=${theme}";
"bat --plain --theme=${theme}";
};
bottomAlias.btm = "btm --group_processes";
in
lib.mkMerge [
lsAliases
catAlias
bottomAlias
];
};
}