nixos/shells: support defining aliases beginning with a dash or plus

Both Zsh and Bash support aliases that begin with characters also used to
indicate options to the “alias” built-in command, as long as the alias
definition is preceeded by a double dash.

This allows, e.g, for “alias -- +x=chmod +x”.
This commit is contained in:
Sebastian Reuße 2022-10-28 08:24:37 +02:00
parent e0e0c4dbd9
commit 5764782921
2 changed files with 2 additions and 2 deletions

View file

@ -12,7 +12,7 @@ let
cfg = config.programs.bash;
bashAliases = concatStringsSep "\n" (
mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}")
mapAttrsFlatten (k: v: "alias -- ${k}=${escapeShellArg v}")
(filterAttrs (k: v: v != null) cfg.shellAliases)
);

View file

@ -12,7 +12,7 @@ let
opt = options.programs.zsh;
zshAliases = concatStringsSep "\n" (
mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}")
mapAttrsFlatten (k: v: "alias -- ${k}=${escapeShellArg v}")
(filterAttrs (k: v: v != null) cfg.shellAliases)
);