Skip to content

build: ship shell completions in deb/rpm/apk packages and the Nix flake - #246

Merged
pranshuparmar merged 2 commits into
pranshuparmar:mainfrom
Self-Perfection:build/package-shell-completions
Nov 21, 2026
Merged

pranshuparmar merged 2 commits into
pranshuparmar:mainfrom
Self-Perfection:build/package-shell-completions

Conversation

@Self-Perfection

@Self-Perfection Self-Perfection commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

witr completion already generates Bash, Zsh and Fish completions, but none of the packages install them, so packaged installs still need a line in the shell config. This PR ships them:

  • deb/rpm/apk (.goreleaser.yml): a before hook generates the three scripts with go run ./cmd/witr completion <shell> into completions/ (gitignored), and nfpm installs them:
    • Bash: /usr/share/bash-completion/completions/witr
    • Fish: /usr/share/fish/vendor_completions.d/witr.fish
    • Zsh: /usr/share/zsh/vendor-completions/_witr for deb, /usr/share/zsh/site-functions/_witr for rpm and apk. Debian's zsh doesn't search site-functions (only /usr/local/share/zsh/site-functions), so one path for all three doesn't work.
  • Nix flake: installShellCompletion with the output of the built binary. It's skipped when cross-compiling, since the binary can't run on the build machine then. The man page is still installed in that case.
  • README: says the packages install the scripts and what each shell needs to pick them up (Fish: nothing; Bash: the bash-completion package; Zsh: compinit). The manual setup stays as the fallback. The old eval line for Zsh needs compinit too, since cobra's script calls compdef.

Why this is useful

  • Lets witr just work and be properly integrated with OS without extra actions from the user.
  • Eliminates slowing down new shell initialization. Completion files are lazy loaded on the first completion attempt

How it was tested

  • goreleaser release --snapshot --clean --skip=publish builds all archives and packages. goreleaser check, gofmt, go vet ./... and go test ./... pass.
  • The amd64 deb, rpm and apk packages were installed in clean debian:trixie, fedora:latest and alpine:latest containers. Bash, Zsh and Fish completions all come up there: Zsh picks _witr up from the per-distro directory, Fish's complete -C "witr --po" returns --port. On Debian sid I also pressed a real Tab in Zsh through a pty, with a control run where _witr was removed.
  • Nix: nix build .#default passes. With the result installed in a nix profile, pressing a real Tab after witr --po (driven through a pty) completes --port in Bash, Zsh and Fish. As a control, the same flake without this change gives no completion in any of them. Fish's man-page completion generator was disabled for that test so it couldn't mask the result.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (may affect existing functionality)
  • This change requires a documentation update

Checklist

  • I have opened this PR against the staging branch, with a Conventional Commits title
  • I have performed a self-review of my own code
  • make lint and make test pass, and my changes add no new compiler, go vet or lint warnings
  • Platform-specific changes are checked in every platform's file (_linux, _darwin, _freebsd, _windows) (n/a, packaging only)
  • Features that exist in both the CLI and the TUI are updated in both (n/a)
  • Output changes are mirrored in the playground (docs/js/engine.js, fixtures regenerated) (n/a)
  • New --json fields are recorded in the JSON contract golden file (n/a)
  • I have made corresponding changes to the documentation (README, agent skill)

This change was prepared with the help of an AI assistant (Claude Code). All the testing above was actually run.

🤖 Generated with Claude Code

Self-Perfection and others added 2 commits October 24, 2026 02:30
GoReleaser generates bash, zsh and fish completions with `witr completion`
before the build and nfpm installs them into each distro's standard
directories. zsh's directory differs per packager: Debian's zsh only
searches vendor-completions, Fedora's and Alpine's search site-functions.

The flake installs the same completions with installShellCompletion,
skipped when cross-compiling since that needs to run the built binary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bash only loads the packaged script through bash-completion and Zsh
through compinit, so keep the manual setup as the fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CJstate

CJstate commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Hi @pranshuparmar, gentle nudge on this one when you have a moment — it's been a couple of weeks since the last look.

Both completions PRs (#246 here and #244 for Record & Replay) are green on the full matrix (60+ checks across linux/darian/windows/freebsd/loong64, lint, coverage, security scan). #246 is the smaller of the two (shell completions in deb/rpm/apk + Nix flake) and has no review comments yet, so it may be the easiest to land first — happy to address anything that comes up.

Also a small heads-up on #244: since it's a bigger feature, if you'd prefer to review it in stages (e.g. the snapshot format first, then the replay path), I can split the PR or add a design summary to the description to make the review easier.

@pranshuparmar pranshuparmar left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Self-Perfection, this should be a good addition.

@Self-Perfection

Copy link
Copy Markdown
Contributor Author

Hi @pranshuparmar

I am a bit confused.

Do you want me to do anything else in this PR? I see that you approved the PR, but have not merged it to any branch yet.

@pranshuparmar

Copy link
Copy Markdown
Owner

Hi @pranshuparmar

I am a bit confused.

Do you want me to do anything else in this PR? I see that you approved the PR, but have not merged it to any branch yet.

@Self-Perfection No further actions needed from your side. I'm collecting issues/enhancements for the next milestone and it can be far out so I'm considering to merge this directly to main so that Nix flake users can benefit from this, hence kept it open. Allow me a few more days, will merge.

@pranshuparmar
pranshuparmar changed the base branch from staging to main November 21, 2026 11:48
@pranshuparmar
pranshuparmar merged commit 5e96686 into pranshuparmar:main Nov 21, 2026
75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants