home/shell: restrict shells for cds

This commit is contained in:
2025-05-21 00:26:14 +02:00
parent 3dcab3e966
commit 8534bc90ea

View File

@@ -370,26 +370,35 @@ in {
# Code generated commands # Code generated commands
"Generated" = { "Generated" = {
"cds" = let "cds" = lib.pipe (lib.range 1 9) [
inherit (lib.strings) concatStringsSep; (map
inherit (extendedLib.strings) repeatString; (n: {
realCommand = "cd " + (builtins.concatStringsSep "/" (lib.replicate n ".."));
inherit (lib.lists) range flatten replicate; aliases = [
inherit (lib.attrsets) nameValuePair listToAttrs; ("cd" + (lib.strings.replicate (n + 1) "."))
("cd." + toString n)
nthCds = n: [ (lib.strings.replicate (n + 1) ".")
("cd" + (repeatString "." (n + 1))) ("." + toString n)
("cd." + toString n) (".." + toString n)
(repeatString "." (n + 1)) ];
("." + toString n) })
(".." + toString n) )
]; (map
realCommand = n: "cd " + (concatStringsSep "/" (replicate n "..")); ({ realCommand, aliases }: map (alias: {
name = alias;
nthCdsAsNameValuePairs = n: map (cmd: nameValuePair cmd (realCommand n)) (nthCds n); value = {
allCdNameValuePairs = flatten (map nthCdsAsNameValuePairs (range 1 9)); alias = [ realCommand ];
in shells = [
listToAttrs allCdNameValuePairs; "bash"
"zsh"
"fish"
];
};
}) aliases)
)
builtins.concatLists
builtins.listToAttrs
];
}; };
}; };