Skip to content

Commit

Permalink
wrapFish: add fish shell wrapper package
Browse files Browse the repository at this point in the history
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
pacien committed Jan 5, 2021
1 parent a14ea3a commit ae5c662
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pkgs/shells/fish/wrapper.nix
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
" "$@"
'')
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8843,6 +8843,8 @@ in

fish = callPackage ../shells/fish { };

wrapFish = callPackage ../shells/fish/wrapper.nix { };

fishPlugins = recurseIntoAttrs (callPackage ../shells/fish/plugins { });

ion = callPackage ../shells/ion {
Expand Down

0 comments on commit ae5c662

Please sign in to comment.