mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 23:11:34 +01:00
shell: Refactor aliases
This commit is contained in:
parent
14b0e0ac1d
commit
9d0a734a73
1 changed files with 31 additions and 20 deletions
|
|
@ -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
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue