diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index ac3663ef..7df9704d 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -207,7 +207,8 @@ let modifiers = if isAttrs def then mods else ""; expansion = if isAttrs def then def.expansion else def; in "abbr --add ${modifiers} -- ${name}" - + optionalString (expansion != null) " \"${expansion}\"") cfg.shellAbbrs); + + optionalString (expansion != null) " ${escapeShellArg expansion}") + cfg.shellAbbrs); aliasesStr = concatStringsSep "\n" (mapAttrsToList (k: v: "alias ${k} ${escapeShellArg v}") cfg.shellAliases); diff --git a/tests/modules/programs/fish/abbrs.nix b/tests/modules/programs/fish/abbrs.nix index 681212b8..ce89bcb0 100644 --- a/tests/modules/programs/fish/abbrs.nix +++ b/tests/modules/programs/fish/abbrs.nix @@ -26,8 +26,13 @@ }; "4DIRS" = { setCursor = "!"; - expansion = - "$(string join \\n -- 'for dir in */' 'cd $dir' '!' 'cd ..' 'end')"; + expansion = '' + for dir in */ + cd $dir + ! + cd .. + end + ''; }; dotdot = { regex = "^\\.\\.+$"; @@ -41,19 +46,24 @@ "if fish.shellAbbrs is set, check fish.config contains valid abbreviations"; script = '' assertFileContains home-files/.config/fish/config.fish \ - 'abbr --add -- l less' + "abbr --add -- l less" assertFileContains home-files/.config/fish/config.fish \ - 'abbr --add -- gco "git checkout"' + "abbr --add -- gco 'git checkout'" assertFileContains home-files/.config/fish/config.fish \ - 'abbr --add --position anywhere -- -C --color' + "abbr --add --position anywhere -- -C --color" assertFileContains home-files/.config/fish/config.fish \ - 'abbr --add --position anywhere --set-cursor -- L "% | less"' + "abbr --add --position anywhere --set-cursor -- L '% | less'" assertFileContains home-files/.config/fish/config.fish \ - 'abbr --add --function last_history_item --position anywhere -- !!' + "abbr --add --function last_history_item --position anywhere -- !!" assertFileContains home-files/.config/fish/config.fish \ "abbr --add --function vim_edit --position command --regex '.+\.txt' -- vim_edit_texts" assertFileContains home-files/.config/fish/config.fish \ - 'abbr --add '"'"'--set-cursor=!'"'"' -- 4DIRS "$(string join \n -- '"'"'for dir in */'"'"' '"'"'cd $dir'"'"' '"'"'!'"'"' '"'"'cd ..'"'"' '"'"'end'"'"')' + "abbr --add '--set-cursor=!' -- 4DIRS 'for dir in */ + cd \$dir + ! + cd .. + end + '" assertFileContains home-files/.config/fish/config.fish \ "abbr --add --function multicd --regex '^\.\.+$' -- dotdot" '';