mirror of
https://github.com/nix-community/home-manager
synced 2024-11-14 07:09:45 +01:00
zsh: improve shell{,Global}Aliases
This commit changes the way aliases are rendered, adding the "no more flags" flag `--`, which means that, for example, the alias `"-" = "cd -";` will work as expected. (I was getting a syntax error before this change.) Additionally, now the alias key is shell escaped, which may help some edge cases. I'm honestly not sure if this part is necessary since I assume an alias can't contain spaces anyway, but it definitely shouldn't break anything.
This commit is contained in:
parent
a2b56736d8
commit
942146ac90
2 changed files with 5 additions and 5 deletions
|
@ -15,7 +15,7 @@ let
|
|||
localVarsStr = config.lib.zsh.defineAll cfg.localVariables;
|
||||
|
||||
aliasesStr = concatStringsSep "\n" (
|
||||
mapAttrsToList (k: v: "alias ${k}=${lib.escapeShellArg v}") cfg.shellAliases
|
||||
mapAttrsToList (k: v: "alias -- ${lib.escapeShellArg k}=${lib.escapeShellArg v}") cfg.shellAliases
|
||||
);
|
||||
|
||||
dirHashesStr = concatStringsSep "\n" (
|
||||
|
@ -638,7 +638,7 @@ in
|
|||
${aliasesStr}
|
||||
''
|
||||
]
|
||||
++ (mapAttrsToList (k: v: "alias -g ${k}=${lib.escapeShellArg v}") cfg.shellGlobalAliases)
|
||||
++ (mapAttrsToList (k: v: "alias -g -- ${lib.escapeShellArg k}=${lib.escapeShellArg v}") cfg.shellGlobalAliases)
|
||||
++ [ (''
|
||||
# Named Directory Hashes
|
||||
${dirHashesStr}
|
||||
|
|
|
@ -23,10 +23,10 @@ with lib;
|
|||
assertFileExists home-files/.zshrc
|
||||
assertFileContains \
|
||||
home-files/.zshrc \
|
||||
"alias ls='@pls@/bin/pls'"
|
||||
"alias -- 'ls'='@pls@/bin/pls'"
|
||||
assertFileContains \
|
||||
home-files/.zshrc \
|
||||
"alias ll='@pls@/bin/pls -d perms -d user -d group -d size -d mtime -d git'"
|
||||
"alias -- 'll'='@pls@/bin/pls -d perms -d user -d group -d size -d mtime -d git'"
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue