Commit 57647829 authored by Sebastian Reuße's avatar Sebastian Reuße
Browse files

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”.
parent e0e0c4db
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)
  );

+1 −1
Original line number Diff line number Diff line
@@ -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)
  );