Merge pull request #191679 from drupol/fish/update-wrapfish

authored by Sandro and committed by GitHub 4af4d2bc ccbff433

+31 -9
+31 -9
pkgs/shells/fish/wrapper.nix
··· 1 - { lib, writeShellScriptBin, fish }: 1 + { lib, writeShellScriptBin, fish, writeTextFile }: 2 2 3 - with lib; 4 - 5 - makeOverridable ({ 3 + lib.makeOverridable ({ 6 4 completionDirs ? [], 7 5 functionDirs ? [], 8 6 confDirs ? [], 9 - pluginPkgs ? [] 7 + pluginPkgs ? [], 8 + localConfig ? "", 9 + shellAliases ? {} 10 10 }: 11 11 12 12 let 13 + aliasesStr = builtins.concatStringsSep "\n" 14 + (lib.mapAttrsToList (k: v: "alias ${k} ${lib.escapeShellArg v}") shellAliases); 15 + 16 + shellAliasesFishConfig = writeTextFile { 17 + name = "wrapfish.aliases.fish"; 18 + destination = "/share/fish/vendor_conf.d/aliases.fish"; 19 + text = '' 20 + status --is-interactive; and begin 21 + # Aliases 22 + ${aliasesStr} 23 + end 24 + ''; 25 + }; 26 + 27 + localFishConfig = writeTextFile { 28 + name = "wrapfish.local.fish"; 29 + destination = "/share/fish/vendor_conf.d/config.local.fish"; 30 + text = localConfig; 31 + }; 32 + 13 33 vendorDir = kind: plugin: "${plugin}/share/fish/vendor_${kind}.d"; 14 34 complPath = completionDirs ++ map (vendorDir "completions") pluginPkgs; 15 35 funcPath = functionDirs ++ map (vendorDir "functions") pluginPkgs; 16 - confPath = confDirs ++ map (vendorDir "conf") pluginPkgs; 36 + confPath = confDirs 37 + ++ (map (vendorDir "conf") pluginPkgs) 38 + ++ (map (vendorDir "conf") [ localFishConfig shellAliasesFishConfig ]); 17 39 18 40 in writeShellScriptBin "fish" '' 19 41 ${fish}/bin/fish --init-command " 20 - set --prepend fish_complete_path ${escapeShellArgs complPath} 21 - set --prepend fish_function_path ${escapeShellArgs funcPath} 22 - set --local fish_conf_source_path ${escapeShellArgs confPath} 42 + set --prepend fish_complete_path ${lib.escapeShellArgs complPath} 43 + set --prepend fish_function_path ${lib.escapeShellArgs funcPath} 44 + set --local fish_conf_source_path ${lib.escapeShellArgs confPath} 23 45 for c in \$fish_conf_source_path/*; source \$c; end 24 46 " "$@" 25 47 '')