mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-25 03:17:13 +00:00
ae5c662182
This adds a wrapper for fish which allows creating shells pre-initialised with some completions, functions, and configuration scripts from given paths or from fish plugin packages (`pkgs.fishPlugins.*`). This is especially handy when one wants to try a plugin in an ephemeral shell. GitHub: see https://github.com/NixOS/nixpkgs/pull/107834#discussion_r550612519
26 lines
756 B
Nix
26 lines
756 B
Nix
{ lib, writeShellScriptBin, fish }:
|
|
|
|
with lib;
|
|
|
|
makeOverridable ({
|
|
completionDirs ? [],
|
|
functionDirs ? [],
|
|
confDirs ? [],
|
|
pluginPkgs ? []
|
|
}:
|
|
|
|
let
|
|
vendorDir = kind: plugin: "${plugin}/share/fish/vendor_${kind}.d";
|
|
complPath = completionDirs ++ map (vendorDir "completions") pluginPkgs;
|
|
funcPath = functionDirs ++ map (vendorDir "functions") pluginPkgs;
|
|
confPath = confDirs ++ map (vendorDir "conf") pluginPkgs;
|
|
safeConfPath = map escapeShellArg confPath;
|
|
|
|
in writeShellScriptBin "fish" ''
|
|
${fish}/bin/fish --init-command "
|
|
set --prepend fish_complete_path ${escapeShellArgs complPath}
|
|
set --prepend fish_function_path ${escapeShellArgs funcPath}
|
|
for c in {${concatStringsSep "," safeConfPath}}/*; source $c; end
|
|
" "$@"
|
|
'')
|