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 }: 2 3 - with lib; 4 - 5 - makeOverridable ({ 6 completionDirs ? [], 7 functionDirs ? [], 8 confDirs ? [], 9 - pluginPkgs ? [] 10 }: 11 12 let 13 vendorDir = kind: plugin: "${plugin}/share/fish/vendor_${kind}.d"; 14 complPath = completionDirs ++ map (vendorDir "completions") pluginPkgs; 15 funcPath = functionDirs ++ map (vendorDir "functions") pluginPkgs; 16 - confPath = confDirs ++ map (vendorDir "conf") pluginPkgs; 17 18 in writeShellScriptBin "fish" '' 19 ${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} 23 for c in \$fish_conf_source_path/*; source \$c; end 24 " "$@" 25 '')
··· 1 + { lib, writeShellScriptBin, fish, writeTextFile }: 2 3 + lib.makeOverridable ({ 4 completionDirs ? [], 5 functionDirs ? [], 6 confDirs ? [], 7 + pluginPkgs ? [], 8 + localConfig ? "", 9 + shellAliases ? {} 10 }: 11 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 + 33 vendorDir = kind: plugin: "${plugin}/share/fish/vendor_${kind}.d"; 34 complPath = completionDirs ++ map (vendorDir "completions") pluginPkgs; 35 funcPath = functionDirs ++ map (vendorDir "functions") pluginPkgs; 36 + confPath = confDirs 37 + ++ (map (vendorDir "conf") pluginPkgs) 38 + ++ (map (vendorDir "conf") [ localFishConfig shellAliasesFishConfig ]); 39 40 in writeShellScriptBin "fish" '' 41 ${fish}/bin/fish --init-command " 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} 45 for c in \$fish_conf_source_path/*; source \$c; end 46 " "$@" 47 '')