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.
This commit is contained in:
parent
ddb7082625
commit
d4d5d9bb4a
3 changed files with 31 additions and 0 deletions
|
|
@ -191,6 +191,21 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
abbreviations = lib.mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = { };
|
||||
example = {
|
||||
ll = "ls -l";
|
||||
gs = "git status";
|
||||
};
|
||||
description = ''
|
||||
An attribute set that maps each abbreviation (the top level attribute
|
||||
names in this option) to its expansion. Unlike aliases, abbreviations
|
||||
are expanded inline in the line editor when a space or enter is pressed,
|
||||
so the expanded command is what ends up in the command history.
|
||||
'';
|
||||
};
|
||||
|
||||
environmentVariables = lib.mkOption {
|
||||
type = types.attrsOf lib.hm.types.nushellValue;
|
||||
default = { };
|
||||
|
|
@ -232,11 +247,16 @@ in
|
|||
|| cfg.extraConfig != ""
|
||||
|| aliasesStr != ""
|
||||
|| cfg.settings != { }
|
||||
|| cfg.abbreviations != { }
|
||||
|| cfg.environmentVariables != { };
|
||||
|
||||
aliasesStr = lib.concatLines (
|
||||
lib.mapAttrsToList (k: v: "alias ${toNushell { } k} = ${v}") cfg.shellAliases
|
||||
);
|
||||
|
||||
abbreviationsStr =
|
||||
lib.optionalString (cfg.abbreviations != { })
|
||||
"$env.config.abbreviations = ${toNushell { } cfg.abbreviations}";
|
||||
in
|
||||
lib.mkIf writeConfig {
|
||||
"${cfg.configDir}/config.nu".text = lib.mkMerge [
|
||||
|
|
@ -275,6 +295,7 @@ in
|
|||
(lib.mkIf (cfg.configFile != null) cfg.configFile.text)
|
||||
cfg.extraConfig
|
||||
aliasesStr
|
||||
abbreviationsStr
|
||||
];
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -29,3 +29,8 @@ let config = {
|
|||
alias "ll" = ls -a
|
||||
alias "multi word alias" = cd -
|
||||
alias "z" = __zoxide_z
|
||||
|
||||
$env.config.abbreviations = {
|
||||
"gs": "git status"
|
||||
"ll": "ls -l"
|
||||
}
|
||||
|
|
@ -38,6 +38,11 @@
|
|||
"z" = "__zoxide_z";
|
||||
};
|
||||
|
||||
abbreviations = {
|
||||
"gs" = "git status";
|
||||
"ll" = "ls -l";
|
||||
};
|
||||
|
||||
settings = {
|
||||
show_banner = false;
|
||||
display_errors.exit_code = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue