From 02e7f9837e926b05b5d188d1cf55bf65752d5870 Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Fri, 3 May 2024 18:24:09 +0200 Subject: [PATCH] Redo ls alias generation --- modules/home/shell/enhancement.nix | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/modules/home/shell/enhancement.nix b/modules/home/shell/enhancement.nix index f04a59c..6c0513a 100644 --- a/modules/home/shell/enhancement.nix +++ b/modules/home/shell/enhancement.nix @@ -16,26 +16,12 @@ home.shellAliases = let lsAliases = let - list = "${lib.getExe pkgs.eza} --header --group --time-style=long-iso --group-directories-first --sort=name --icons=auto --git --git-repos-no-status --binary"; - - convertFlagAliasToFlag = char: - { - a = "--all"; - d = "--only-dirs"; - f = "--only-files"; - } - .${char}; - convertFlagAliasesToFlags = str: "${lib.concatStringsSep " " (lib.forEach (lib.stringToCharacters str) convertFlagAliasToFlag)}"; - flagAliasCombos = lib.crossLists (a: b: "${a}${b}") [["" "a"] ["" "d" "f"]]; - flagAttrs = lib.genAttrs flagAliasCombos convertFlagAliasesToFlags; - aliasTemplate = name: value: { - "l${name}" = "${list} --oneline --dereference ${value}"; - "ll${name}" = "${list} --long ${value}"; - "lt${name}" = "${list} --tree ${value}"; - }; - flaggedAliases = lib.concatMapAttrs aliasTemplate flagAttrs; + listCmd = "${lib.getExe pkgs.eza} --header --group --time-style=long-iso --group-directories-first --sort=name --icons=auto --git --git-repos-no-status --binary"; + aliasList = lib.crossLists (a: b: c: "${a}${b}${c}") [["ll" "lt" "l"] ["" "a"] ["" "d" "f"]]; + convertAliasToCmd = str: "${listCmd} " + (builtins.replaceStrings ["ll" "lt" "l" "a" "d" "f"] ["--long " "--tree " "--oneline --dereference " "--all " "--only-dirs " "--only-files "] str); + aliasAttrs = lib.genAttrs aliasList convertAliasToCmd; in - flaggedAliases // {ls = "l";}; + aliasAttrs // {ls = "l";}; catAlias = let theme =