Shell Completion
Enable tab completion for the OneMCP CLI to speed up your workflow.
What is Shell Completion?
Shell completion allows you to press TAB to:
- Auto-complete command names
- Show available subcommands
- Complete flags and options
Example:
onemcp ha<TAB> → autocompletes to "handbook"
onemcp handbook <TAB> → shows: init, list, use, current, validate
onemcp provider <TAB> → shows: list, set, switchSetup Instructions
Bash
Option 1: Add to ~/.bashrc (Recommended)
# Add this line to ~/.bashrc
source <(onemcp completion bash)Then reload:
source ~/.bashrcOption 2: System-wide installation
onemcp completion bash | sudo tee /etc/bash_completion.d/onemcpZsh
Option 1: Add to ~/.zshrc (Recommended)
# Add this line to ~/.zshrc
source <(onemcp completion zsh)Then reload:
source ~/.zshrcOption 2: Save to completion directory
onemcp completion zsh > ~/.zsh/completion/_onemcpMake sure your ~/.zshrc includes:
fpath=(~/.zsh/completion $fpath)
autoload -Uz compinit && compinitFish
Installation:
onemcp completion fish > ~/.config/fish/completions/onemcp.fishFish will automatically load the completion on next shell start.
Reload immediately:
source ~/.config/fish/config.fishPowerShell
Option 1: Add to PowerShell Profile (Recommended)
- Open your PowerShell profile:
notepad $PROFILE- Add this line:
onemcp completion powershell | Out-String | Invoke-Expression- Reload:
. $PROFILEOption 2: Session-only (temporary)
onemcp completion powershell | Out-String | Invoke-ExpressionThis must be run in each new PowerShell session.
Usage Examples
After setup, completion works automatically:
Command Completion
onem<TAB> → onemcp
onemcp <TAB> → shows all commandsSubcommand Completion
onemcp h<TAB> → handbook
onemcp handbook <TAB> → init list use current validateProvider Completion
onemcp provider <TAB> → list set switchFlags Completion
onemcp logs -<TAB> → -n -f --lines --follow --helpVerification
Test that completion is working:
# Type this and press TAB twice
onemcp <TAB><TAB>You should see all available commands:
chat handbook logs provider status update
completion help doctor reset service stopTroubleshooting
Completion Not Working
Bash:
# Verify completion script loaded
type _onemcp
# If not found, reload
source ~/.bashrcZsh:
# Check fpath includes completion directory
echo $fpath
# Rebuild completion cache
rm -f ~/.zcompdump
compinitFish:
# Verify completion file exists
ls ~/.config/fish/completions/onemcp.fish
# Reload completions
fish_update_completionsPowerShell:
# Verify profile was loaded
$PROFILE
# Reload profile
. $PROFILECompletion Shows Wrong Commands
This usually means you have an outdated completion script.
Solution:
- Remove old completion
- Regenerate with latest CLI
- Reload shell
Example (Bash):
# Remove old
sudo rm /etc/bash_completion.d/onemcp
# Regenerate
onemcp completion bash | sudo tee /etc/bash_completion.d/onemcp
# Reload
source ~/.bashrcCompletion Slow
If completion feels slow, it may be regenerating on each invocation.
Solution: Save to a file instead of sourcing dynamically.
Before (slow):
source <(onemcp completion bash) # Regenerates each timeAfter (fast):
onemcp completion bash > ~/.onemcp-completion.bash
source ~/.onemcp-completion.bashAdvanced Configuration
Custom Completion Behavior
You can customize how completion behaves by editing the generated script.
Location depends on method:
- Bash:
~/.onemcp-completion.bashor/etc/bash_completion.d/onemcp - Zsh:
~/.zsh/completion/_onemcp - Fish:
~/.config/fish/completions/onemcp.fish - PowerShell: Added to
$PROFILE
Note: Customizations will be lost if you regenerate the completion script.
Uninstalling Completion
Bash
From ~/.bashrc:
# Remove this line from ~/.bashrc
source <(onemcp completion bash)
# Reload
source ~/.bashrcSystem-wide:
sudo rm /etc/bash_completion.d/onemcpZsh
From ~/.zshrc:
# Remove this line from ~/.zshrc
source <(onemcp completion zsh)
# Reload
source ~/.zshrcCompletion file:
rm ~/.zsh/completion/_onemcpFish
rm ~/.config/fish/completions/onemcp.fishPowerShell
Remove from profile:
- Open profile:
notepad $PROFILE - Remove the completion line
- Save and reload:
. $PROFILE
Benefits
Faster workflow:
- No need to remember exact command names
- Quick access to subcommands
- Less typing overall
Fewer errors:
- See available options before running
- Avoid typos in command names
- Discover new commands
Better discoverability:
- Learn about commands you didn’t know existed
- Explore subcommands interactively
Next Steps
- CLI Guide: See CLI Guide for command usage
- CLI Reference: Check CLI Reference for all commands
- Getting Started: Start with Getting Started