Skip to content

Commit

Permalink
nushell: allow multi-word aliases
Browse files Browse the repository at this point in the history
Also fix invalid alias in test
  • Loading branch information
JoaquinTrinanes authored and rycee committed Jan 29, 2025
1 parent 709aaab commit 82455a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 6 additions & 2 deletions modules/programs/nushell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ in {
shellAliases = lib.mkOption {
type = types.attrsOf types.str;
default = { };
example = { ll = "ls -l"; };
example = {
ll = "ls -l";
g = "git";
};
description = ''
An attribute set that maps aliases (the top level attribute names in
this option) to command strings or directly to build outputs.
Expand Down Expand Up @@ -202,7 +205,8 @@ in {
|| aliasesStr != "" || cfg.settings != { };

aliasesStr = lib.concatLines
(lib.mapAttrsToList (k: v: "alias ${k} = ${v}") cfg.shellAliases);
(lib.mapAttrsToList (k: v: "alias ${toNushell { } k} = ${v}")
cfg.shellAliases);
in lib.mkIf writeConfig {
"${configDir}/config.nu".text = lib.mkMerge [
(let
Expand Down
5 changes: 3 additions & 2 deletions tests/modules/programs/nushell/config-expected.nu
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ let config = {
}


alias ll = ls -a
alias lsname = (ls | get name)
alias "ll" = ls -a
alias "multi word alias" = cd -
alias "z" = __zoxide_z
3 changes: 2 additions & 1 deletion tests/modules/programs/nushell/example-settings.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
plugins = [ pkgs.nushellPlugins.formats ];

shellAliases = {
"lsname" = "(ls | get name)";
"ll" = "ls -a";
"multi word alias" = "cd -";
"z" = "__zoxide_z";
};

settings = {
Expand Down

0 comments on commit 82455a8

Please sign in to comment.