home/nushell: Propose packages for unknown commands

This commit is contained in:
Mikael 2024-10-01 21:04:19 +02:00
parent ec7f3f35cb
commit 0e717bf41e
Signed by: mikael
SSH key fingerprint: SHA256:21QyD2Meiot7jOUVitIR5YkGB/XuXdCvLW1hE6dsri0

View file

@ -299,6 +299,29 @@ in {
}
}
]
hooks: {
command_not_found: {
|cmd_name| (
try {
let pkgs = (
`${config.programs.nix-index.package}/bin/nix-locate`
--top-level --type x --type s --no-group --whole-name --at-root --minimal
$"/bin/($cmd_name)"
)
if ($pkgs | is-empty) {
null
} else {
$pkgs | split row "\n"
| each {|pkg| $" nixpkgs#($pkg)\n"}
| prepend $"($cmd_name) is provided by:\n"
| append "\n" | str join
}
}
)
}
}
};
'';
};