Add zsh completions

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-01-10 16:35:58 +00:00
parent 465198f3c8
commit d967d5d603
9 changed files with 101 additions and 126 deletions

View File

@@ -2,12 +2,14 @@
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ ... }:
{ lib, inputs, ... }:
{
home-manager.users.${user}.programs.zsh = {
shellAliases.nd = "nix-develop";
initExtra = ''
initExtra = let
devShells = lib.strings.concatStringsSep " " (lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells);
in ''
nix-develop() {
if [ -z "$1" ]; then
echo "Usage: nix-develop <shell>"
@@ -15,6 +17,13 @@
fi
nix develop self#"$1" -c "$SHELL"
}
_nix-develop-completion() {
local shells=(${devShells})
compadd -- $shells
}
compdef _nix-develop-completion nix-develop
'';
};
}