Shell Completion for CCS
Tab completion for CCS commands, subcommands, profiles, and flags.
The completion scripts are thin adapters over the hidden ccs __complete backend so
all supported shells stay aligned with the same command graph.
Supported Shells: Bash, Zsh, Fish, PowerShell
Features
- Complete profile names (both settings-based and account-based)
- Complete root commands, help topics, provider shortcuts, and command flags
- Complete
ccs authandccs apilifecycle subcommands - Context-aware: suggests relevant options based on current command
Quick Install (Recommended)
ccs --shell-completion
This will:
- Auto-detect your shell
- Copy completion files to
~/.ccs/completions/ - Configure your shell profile with proper comment markers
- Show instructions to activate
Manual shell selection:
ccs --shell-completion --bash # Force bash
ccs --shell-completion --zsh # Force zsh
ccs --shell-completion --fish # Force fish
ccs --shell-completion --powershell # Force PowerShell
Help and verification:
ccs help completion
ccs --shell-completion --force
Manual Installation
Completion files are installed to ~/.ccs/completions/ during npm install.
Bash
Add to ~/.bashrc or ~/.bash_profile:
# CCS shell completion
source ~/.ccs/completions/ccs.bash
Then reload:
source ~/.bashrc
Zsh
-
Create completion directory:
mkdir -p ~/.zsh/completion -
Copy completion file:
cp ~/.ccs/completions/ccs.zsh ~/.zsh/completion/_ccs -
Add to
~/.zshrc:# CCS shell completion fpath=(~/.zsh/completion $fpath) autoload -Uz compinit && compinit -
Reload:
source ~/.zshrc
PowerShell
Add to your PowerShell profile ($PROFILE):
# CCS shell completion
. "$HOME\.ccs\completions\ccs.ps1"
Then reload:
. $PROFILE
Fish
User installation (recommended)
Fish automatically loads completions from ~/.config/fish/completions/:
# Create completion directory if it doesn't exist
mkdir -p ~/.config/fish/completions
# Copy completion script
cp scripts/completion/ccs.fish ~/.config/fish/completions/
That's it! Fish will automatically load the completion on demand. No need to source or reload.
System-wide installation (requires sudo)
sudo cp scripts/completion/ccs.fish /usr/share/fish/vendor_completions.d/
Usage Examples
Basic Completion
$ ccs <TAB>
auth api cliproxy config doctor docker help
$ ccs help <TAB>
profiles providers completion targets
Context Completion
$ ccs auth show <TAB>
work personal team --json
$ ccs api <TAB>
create list discover copy export import remove
Backend Contract
$ ccs __complete --shell bash --current do
doctor
docker
Shell adapters now call the shared CCS completion backend instead of maintaining their own copy of the command graph. That means:
- top-level commands, help topics, and provider shortcuts come from CCS itself
- dynamic profiles and CLIProxy variants resolve through the real config loaders
- bash, zsh, fish, and PowerShell stay aligned with the same completion logic
Troubleshooting
Bash
- Check if completion is loaded:
complete -p ccs - Verify the backend directly:
ccs __complete --shell bash --current "" -- help
Zsh
- Verify completion system is enabled:
autoload -Uz compinit && compinit - Rebuild the cache if needed:
rm ~/.zcompdump && compinit - Verify the backend directly:
ccs __complete --shell zsh --current "" -- help
PowerShell
- Check that the profile exists:
Test-Path $PROFILE - Verify the backend directly:
ccs __complete --shell powershell --current "" -- help
Fish
- Verify completion file location:
ls ~/.config/fish/completions/ccs.fish - Test completion manually:
complete -C'ccs ' - Verify the backend directly:
ccs __complete --shell fish --current "" -- help
Technical Details
- Bash uses
complete -F - Zsh uses a custom
_ccscompletion function - Fish uses
complete -awith backend command substitution - PowerShell uses
Register-ArgumentCompleter - All four shells now delegate suggestion logic to
ccs __complete
Contributing
When adding or changing command surfaces:
- Update the shared TypeScript command/completion catalog
- Run
bun run validate - Smoke-check at least one installed shell adapter plus the backend directly