2.home-manager/tests/modules/programs/nushell/example-settings.nix
Dzming Li d4d5d9bb4a nushell: add abbreviations option
Add `programs.nushell.abbreviations`, mirroring `shellAliases`, to
declaratively configure fish-style abbreviations (nushell 0.113.0+).
The set is emitted as `$env.config.abbreviations = { ... }` after the
aliases so it survives a wholesale `$env.config = { ... }` written in
`extraConfig`.

Unlike aliases, abbreviations expand inline in the line editor, so the
expanded command is what ends up in history.
2026-06-07 21:06:57 -05:00

87 lines
1.8 KiB
Nix

{
pkgs,
realPkgs,
config,
lib,
...
}:
{
programs.nushell = {
enable = true;
package = realPkgs.nushell;
configFile.text = ''
let config = {
filesize_metric: false
table_mode: rounded
use_ls_colors: true
}
'';
envFile.text = ''
$env.FOO = 'BAR'
'';
loginFile.text = ''
# Prints "Hello, World" upon logging into tty1
if (tty) == "/dev/tty1" {
echo "Hello, World"
}
'';
plugins = [ realPkgs.nushellPlugins.formats ];
shellAliases = {
"ll" = "ls -a";
"multi word alias" = "cd -";
"z" = "__zoxide_z";
};
abbreviations = {
"gs" = "git status";
"ll" = "ls -l";
};
settings = {
show_banner = false;
display_errors.exit_code = false;
hooks.pre_execution = [ (lib.hm.nushell.mkNushellInline ''{|| "pre_execution hook"}'') ];
};
environmentVariables = {
FOO = "BAR";
LIST_VALUE = [
"foo"
"bar"
];
PROMPT_COMMAND = lib.hm.nushell.mkNushellInline ''{|| "> "}'';
ENV_CONVERSIONS.PATH = {
from_string = lib.hm.nushell.mkNushellInline "{|s| $s | split row (char esep) }";
to_string = lib.hm.nushell.mkNushellInline "{|v| $v | str join (char esep) }";
};
};
};
nmt.script =
let
configDir =
if pkgs.stdenv.isDarwin && !config.xdg.enable then
"home-files/Library/Application Support/nushell"
else
"home-files/.config/nushell";
in
''
assertFileContent \
"${configDir}/config.nu" \
${./config-expected.nu}
assertFileContent \
"${configDir}/env.nu" \
${./env-expected.nu}
assertFileContent \
"${configDir}/login.nu" \
${./login-expected.nu}
assertFileExists \
"${configDir}/plugin.msgpackz"
'';
}