fish: add develop function

This commit is contained in:
ooks-io 2024-10-31 17:28:43 +11:00
parent f1ebe05f1d
commit 68a46a0160
3 changed files with 37 additions and 0 deletions

View file

@ -13,6 +13,7 @@ in {
./plugins.nix
./binds.nix
./aliases.nix
./functions
];
options.ooknet.home.fish.enable = mkEnableOption "";

View file

@ -0,0 +1,5 @@
{
imports = [
./develop.nix
];
}

View file

@ -0,0 +1,31 @@
{
self,
pkgs,
...
}: let
# get devshell names from flake
devShellNames = builtins.concatStringsSep " " (builtins.attrNames self.devShells.${pkgs.system});
in {
programs.fish = {
# add devshells completions to init script
interactiveShellInit = ''
complete -c develop -f -a "${devShellNames}"
'';
functions.develop = {
description = "Easily jump into any of the ooknet devshells";
body =
#fish
''
if test -n "$argv[1]"
if test -n "$FLAKE"
nix develop $FLAKE#$argv[1]
else
echo "error: FLAKE variable is not set";
end
else
echo "error: No argument was provided";
end
'';
};
};
}