forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wrapFish: add fish shell wrapper package
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 NixOS#107834 (comment)
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ 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 | ||
" "$@" | ||
'') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters