feat: Add shell completion installation and setup commands - #630
Merged
Conversation
razor-x
force-pushed
the
claude/seam-completion-install-jisy37
branch
4 times, most recently
from
August 18, 2026 05:08
14646c8 to
d3ae8aa
Compare
Installing completions meant knowing where each shell keeps them. Do that instead. 'seam completion --install' works out which shell it was run from, or takes one as an argument, and adds a line loading the completion loader to that shell's config, or writes the loader itself for fish, which loads a completion file on demand. It is safe to repeat, since a config that already has the line is left alone. Installing by hand is the same line: echo 'eval "$(seam completion --loader zsh 2> /dev/null)"' >> ~/.zshrc The shell comes from the process that ran the command rather than from SHELL, which names the login shell and so answers bash for every shell started from one. The loader is asked for quietly because a shell config runs it on every new shell: an older seam that cannot print a loader, or no seam at all, then completes nothing rather than reporting itself over and over at a prompt. The loader keeps its job of being what a system package installs, and now also survives being evaluated by a shell config. It could not be before: the zsh loader declared a local outside a function, which is an error anywhere but the completion function it was assumed to be, and registered nothing when it was not one. Bash gains the same, registering its own completion so that it needs neither the bash-completion package nor a config entry, and completing on demand wherever bash is new enough to. The zsh loader never runs compinit: that would override the dumpfile and options the shell owner chose. It registers once the completion system is up, and --install says so when nothing in the config turns it on. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NS3fVoYWNDEQWAhrp3PnPj
razor-x
force-pushed
the
claude/seam-completion-install-jisy37
branch
from
August 18, 2026 05:26
d3ae8aa to
c1d209c
Compare
razor-x
commented
Aug 18, 2026
razor-x
marked this pull request as ready for review
August 18, 2026 05:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds the ability to install and configure shell completions for bash, fish, and zsh directly from the CLI, rather than requiring manual installation or system package management.
Key Changes
New completion installation module (
src/lib/completion/install.ts):detectShell(): Detects the current shell from theSHELLenvironment variableresolveCompletionTarget(): Determines where completions should be installed based on shell type and environment variables (e.g.,ZDOTDIRfor zsh,XDG_CONFIG_HOMEfor fish)installCompletion(): Handles the actual installation, with idempotent behavior for config files (appends only once) and overwrites for completion files owned by the CLINew completion setup rendering (
src/lib/render/completion/render-loader.ts):renderCompletionSetup(): Generates the snippet users add to their shell configrenderCompletionStub(): Generates the loader for system packages (moved from index.ts)completionSetupMarker: Constant used to detect already-installed snippetsEnhanced completion command (
src/lib/commands/local/completion.ts):--installflag: Automatically installs completions into the detected shell's config--manualflag: Prints the setup snippet for manual installationreadCompletionAction(): Parses which action to perform (print, install, manual, or loader)resolveCompletionShell(): Determines the target shell from arguments or environmentinstallCompletionForShell(): Orchestrates the installation and reports resultsprintCompletionSetup(): Prints the snippet with instructionsRefactored completion rendering (
src/lib/render/completion/):shell.tsmodulerender-loader.tsindex.tsto re-export from new modulesComprehensive test coverage (
test/completion/install.test.ts):SHELLvaluesCLI integration (
src/bin/cli.ts):Documentation updates (
README.md):--install,--manual, and--loaderflagsNotable Implementation Details
completionSetupMarkerbefore appending, preventing duplicate snippetsseam completionon first use, ensuring completions always match the current CLI schemaZDOTDIRand can initializecompinitif needed.bashrcon Linux but falls back to.bash_profileon macOShttps://claude.ai/code/session_01NS3fVoYWNDEQWAhrp3PnPj