Skip to content

feat: add shell completions (bash, zsh, fish) - #4943

Open
gitmpr wants to merge 1 commit into
anthropics:mainfrom
gitmpr:feat/shell-completion-scripts
Open

gitmpr wants to merge 1 commit into
anthropics:mainfrom
gitmpr:feat/shell-completion-scripts

Conversation

@gitmpr

@gitmpr gitmpr commented Aug 1, 2025

Copy link
Copy Markdown

Adds static completion scripts for tab autocompletion under shell-completions/:

  • claude-completions.bash
  • claude-completions.zsh
  • claude-completions.fish

Note: If the claude binary supported integrated completions, users would simply be able to run:

source <(claude completion $SHELL)

as is common in many modern CLI tools.

Unfortunately, upstream integration isn’t possible. The client is not open source.

Adds static completion scripts under shell-completions/:
- claude-completions.bash
- claude-completions.zsh
- claude-completions.fish

Note: If the claude binary supported integrated completions,
users would simply be able to run:

    source <(claude completion $SHELL)

as is common in many modern CLI tools.

Unfortunately, upstream integration isn’t possible
the client is not open source.
@gitmpr
gitmpr force-pushed the feat/shell-completion-scripts branch from d8cb78c to 8a0febd Compare August 1, 2025 19:33
@dexxiez

dexxiez commented Aug 1, 2025

Copy link
Copy Markdown

Would be good if the team took 3 minutes to run claude code on their project to make these into upstream. xoxox

@1160054

1160054 commented Dec 17, 2025

Copy link
Copy Markdown

Hi @gitmpr, thanks for working on shell completions for Claude Code!

I've also been working on a Zsh completion script and wanted to share it in case it's helpful:
https://github.com/1160054/claude-code-zsh-completion

Some features that might be worth considering:

  • Multi-language support: Completion descriptions in 120+ languages
  • Dynamic completions: Shows user's configured MCP servers when typing claude mcp remove <TAB>, installed plugins for claude plugin uninstall <TAB>, etc.
  • Plugin manager support: Ready-to-use with zinit, antigen, sheldon, and Oh My Zsh

Feel free to use any parts of it if you find them useful. I'm happy to collaborate or contribute if needed.

demo

@mishraprafful

Copy link
Copy Markdown

Cross-linking #62455 for visibility — it's a fresh feature request for tab completion inside bash mode (the ! prefix in the TUI), filed after #18637 was auto-closed for inactivity.

That's a different layer than this PR (which adds completion for the external claude command in the user's shell), but they're often conflated by people searching for the same problem, so worth keeping the threads connected.

@AzarAI-TOP

Copy link
Copy Markdown

For anyone who wants shell completion today while this is pending: I put together a small repo that takes a slightly different approach from static scripts.

Instead of hard-coding a flag/subcommand list (which goes stale on every Claude Code release), the scripts parse claude --help at runtime and cache the result per version, so completion always matches the claude you actually have installed.

  • bash / zsh / fish
  • lazy-loaded into the user-level completion dirs — no ~/.bashrc edit
  • ./install.sh auto-detects your current shell (or pass bash/zsh/fish/all)

https://github.com/AzarAI-TOP/bash-completion-for-claude

Not a substitute for first-class support, but it sidesteps the maintenance problem in the meantime. Happy to fold improvements back in.

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.

5 participants