From 85faa0af11b8b11c1c96390fbeab6964b7ba6638 Mon Sep 17 00:00:00 2001 From: faukah Date: Mon, 23 Nov 2026 09:11:44 +0100 Subject: [PATCH 1/2] cli: add shell completions Signed-off-by: faukah Change-Id: I179afb946047f8e7c1d0d560276a1ecd6a6a6964 --- Cargo.lock | 10 ++++++++++ Cargo.toml | 1 + src/main.rs | 1 + 3 files changed, 12 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 73e5e5c..5d4a896 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,10 +8,20 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +[[package]] +name = "caress" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8769b95e8254ef7093e5b44e11dc1f43a5550c1944079298f0a47955bd30b12" +dependencies = [ + "pound", +] + [[package]] name = "inshellah" version = "0.2.0" dependencies = [ + "caress", "libc", "miniz_oxide", "nom", diff --git a/Cargo.toml b/Cargo.toml index de55907..725f379 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ categories = [ "command-line-utilities" ] include = [ "LICENSE", "README.md", "doc", "src" ] [dependencies] +caress = "0.3.0" libc = "0.2.186" miniz_oxide = { version = "0.9.1", features = [ "std" ] } nom = "8.0.0" diff --git a/src/main.rs b/src/main.rs index 3f3ff3d..95df307 100644 --- a/src/main.rs +++ b/src/main.rs @@ -131,6 +131,7 @@ fn resolve_dirs(dirs: Dirs) -> Vec { } fn main() { + caress::handle(Cli::SPEC); // rust ignores SIGPIPE, so a broken-pipe write becomes a BrokenPipe error // that `println!` panics on. restore the default so piping into `head` // exits quietly. From 9cd2c2d41328533d4904721d6f6b32703da40555 Mon Sep 17 00:00:00 2001 From: faukah Date: Mon, 23 Nov 2026 09:13:26 +0100 Subject: [PATCH 2/2] {nix, docs}: add and document shell completions Signed-off-by: faukah Change-Id: Ic95faaa1c79b95db76a3d70430c441026a6a6964 --- README.md | 13 +++++++++++++ nix/package.nix | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/README.md b/README.md index e65d1c8..07d3cd7 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,19 @@ see `doc/` for details: - [runtime completions](doc/runtime-completions.md) — on-the-fly caching via the completer - [changelog](CHANGELOG.md) — breaking changes between releases +## shell completions + +the nix package installs completions for bash, zsh, fish and nushell. to set +completions up by hand, source the script inshellah prints. + +| shell | setup | +|--------|--------------------------------------------------------------------| +| bash | `source <(COMPLETE=bash inshellah)` | +| zsh | `COMPLETE=zsh inshellah > ~/.zfunc/_inshellah`, with it in `fpath` | +| fish | `COMPLETE=fish inshellah \| source` | +| nu | `COMPLETE=nu inshellah \| save inshellah.nu`, then `source` it | +| elvish | `eval (env COMPLETE=elvish inshellah \| slurp)` | + ## license EUPL-1.2. see [LICENSE](LICENSE) diff --git a/nix/package.nix b/nix/package.nix index f8a461d..070b38b 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -1,6 +1,9 @@ { lib, + stdenv, + buildPackages, rustPlatform, + installShellFiles, nushell, }: rustPlatform.buildRustPackage { @@ -8,7 +11,22 @@ rustPlatform.buildRustPackage { version = (lib.importTOML ../Cargo.toml).package.version; src = import ./src.nix lib; cargoLock.lockFile = ../Cargo.lock; + nativeBuildInputs = [ installShellFiles ]; nativeCheckInputs = [ nushell ]; + + postInstall = lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) ( + let + inshellah = "${stdenv.hostPlatform.emulator buildPackages} $out/bin/inshellah"; + in + '' + installShellCompletion --cmd inshellah \ + --bash <(COMPLETE=bash ${inshellah}) \ + --zsh <(COMPLETE=zsh ${inshellah}) \ + --fish <(COMPLETE=fish ${inshellah}) \ + --nushell <(COMPLETE=nu ${inshellah}) + '' + ); + meta = { description = "nushell completion indexer"; mainProgram = "inshellah";