mirror of
https://github.com/nix-community/home-manager
synced 2024-12-25 03:09:47 +01:00
nushell: add shellAliases option
This allows nushell users to define shell aliases that are inserted into nushell's `config.nu`.
This commit is contained in:
parent
6db559daa9
commit
58b8685e47
3 changed files with 28 additions and 1 deletions
|
@ -111,17 +111,36 @@ in {
|
||||||
Additional configuration to add to the nushell environment variables file.
|
Additional configuration to add to the nushell environment variables file.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
shellAliases = mkOption {
|
||||||
|
type = types.attrsOf types.str;
|
||||||
|
default = { };
|
||||||
|
example = { ll = "ls -l"; };
|
||||||
|
description = ''
|
||||||
|
An attribute set that maps aliases (the top level attribute names in
|
||||||
|
this option) to command strings or directly to build outputs.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
home.file = mkMerge [
|
home.file = mkMerge [
|
||||||
(mkIf (cfg.configFile != null || cfg.extraConfig != "") {
|
(let
|
||||||
|
writeConfig = cfg.configFile != null || cfg.extraConfig != ""
|
||||||
|
|| aliasesStr != "";
|
||||||
|
|
||||||
|
aliasesStr = concatStringsSep "\n"
|
||||||
|
(mapAttrsToList (k: v: "alias ${k} = ${v}") cfg.shellAliases);
|
||||||
|
in mkIf writeConfig {
|
||||||
"${configDir}/config.nu".text = mkMerge [
|
"${configDir}/config.nu".text = mkMerge [
|
||||||
(mkIf (cfg.configFile != null) cfg.configFile.text)
|
(mkIf (cfg.configFile != null) cfg.configFile.text)
|
||||||
cfg.extraConfig
|
cfg.extraConfig
|
||||||
|
aliasesStr
|
||||||
];
|
];
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf (cfg.envFile != null || cfg.extraEnv != "") {
|
(mkIf (cfg.envFile != null || cfg.extraEnv != "") {
|
||||||
"${configDir}/env.nu".text = mkMerge [
|
"${configDir}/env.nu".text = mkMerge [
|
||||||
(mkIf (cfg.envFile != null) cfg.envFile.text)
|
(mkIf (cfg.envFile != null) cfg.envFile.text)
|
||||||
|
|
|
@ -4,3 +4,6 @@ let $config = {
|
||||||
use_ls_colors: true
|
use_ls_colors: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
alias ll = ls -a
|
||||||
|
alias lsname = (ls | get name)
|
|
@ -15,6 +15,11 @@
|
||||||
envFile.text = ''
|
envFile.text = ''
|
||||||
let-env FOO = 'BAR'
|
let-env FOO = 'BAR'
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
shellAliases = {
|
||||||
|
"lsname" = "(ls | get name)";
|
||||||
|
"ll" = "ls -a";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
test.stubs.nushell = { };
|
test.stubs.nushell = { };
|
||||||
|
|
Loading…
Reference in a new issue