completions
Generate shell completion scripts for bash, zsh, fish, and PowerShell.
When to Use This
Section titled “When to Use This”- First-time setup — After installing sql-splitter, generate completions to enable tab completion
- After upgrading — Regenerate completions when new commands or flags are added
- Setting up a new machine — Include completion setup in your dotfiles or provisioning scripts
- Switching shells — Generate completions for your new shell
How It Works
Section titled “How It Works”The completions command uses clap’s built-in completion generator to produce shell-specific scripts. When loaded by your shell, these scripts intercept Tab key presses and provide context-aware suggestions for commands, flags, and flag values.
Completions are generated at runtime based on the current version of sql-splitter, so they always reflect the available commands and options.
sql-splitter completions <SHELL>Supported Shells
Section titled “Supported Shells”| Shell | Value |
|---|---|
| Bash | bash |
| Zsh | zsh |
| Fish | fish |
| PowerShell | powershell |
Installation
Section titled “Installation”Once installed to the correct location, completions persist across shell restarts—no need to regenerate unless you upgrade sql-splitter.
Bash supports two installation methods:
System-wide (all users, requires sudo):
sudo sql-splitter completions bash > /etc/bash_completion.d/sql-splitterUser-only (recommended):
# Create completions directory if neededmkdir -p ~/.bash_completion.d
# Generate completionssql-splitter completions bash > ~/.bash_completion.d/sql-splitter
# Add to .bashrc (one-time setup)echo 'source ~/.bash_completion.d/sql-splitter' >> ~/.bashrc
# Reload current sessionsource ~/.bashrcZsh loads completions from directories in $fpath. Find your fpath locations:
echo $fpath | tr ' ' '\n'Standard installation:
# Use the first writable fpath directory (usually ~/.zsh/completions or similar)sql-splitter completions zsh > "${fpath[1]}/_sql-splitter"
# Rebuild completion cache and reloadautoload -Uz compinit && compinitsource ~/.zshrcOh-My-Zsh:
# Oh-My-Zsh includes ~/.oh-my-zsh/completions in fpathmkdir -p ~/.oh-my-zsh/completionssql-splitter completions zsh > ~/.oh-my-zsh/completions/_sql-splitter
# Reloadsource ~/.zshrcIf you don’t have a user fpath directory:
# Create one and add to fpath in .zshrcmkdir -p ~/.zsh/completionsecho 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrcsql-splitter completions zsh > ~/.zsh/completions/_sql-splittersource ~/.zshrcFish has a dedicated completions directory that’s automatically loaded:
# Create directory if neededmkdir -p ~/.config/fish/completions
# Generate completions (takes effect immediately in new shells)sql-splitter completions fish > ~/.config/fish/completions/sql-splitter.fishNo reload required—Fish automatically picks up new completion files.
PowerShell
Section titled “PowerShell”PowerShell loads completions from your profile script. Find your profile location:
echo $PROFILE# Typically: ~/.config/powershell/Microsoft.PowerShell_profile.ps1 (Linux/macOS)# Or: ~/Documents/PowerShell/Microsoft.PowerShell_profile.ps1 (Windows)Install completions:
# Create profile if it doesn't existif (!(Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force }
# Append completions to profilesql-splitter completions powershell >> $PROFILE
# Reload profile. $PROFILEWhat Completions Provide
Section titled “What Completions Provide”Once installed, pressing Tab will autocomplete:
- Command names (
split,analyze,merge, etc.) - Command aliases (
sp,an,mg, etc.) - Flag names (
--output,--dialect, etc.) - Flag values (e.g., dialect options:
mysql,postgres,sqlite,mssql)
Example
Section titled “Example”$ sql-splitter sp<TAB>$ sql-splitter split
$ sql-splitter split dump.sql --dia<TAB>$ sql-splitter split dump.sql --dialect
$ sql-splitter split dump.sql --dialect <TAB>mysql postgres sqlite mssqlVerification
Section titled “Verification”After installation, test completions:
# Type and press Tabsql-splitter <TAB>
# Should show all commands:# analyze completions convert diff graph merge order query redact sample shard split validateTroubleshooting
Section titled “Troubleshooting”Completions not working
Section titled “Completions not working”Shell needs reload: After installing completions, you must reload your shell configuration or open a new terminal:
# Bashsource ~/.bashrc
# Zshsource ~/.zshrc
# Fish (usually automatic, but try)source ~/.config/fish/config.fish
# PowerShell. $PROFILEZsh fpath issues: Ensure the completion file is in a directory listed in $fpath and the filename starts with _:
# Check if the file is in fpathecho $fpath | tr ' ' '\n' | xargs -I {} ls {}_sql-splitter 2>/dev/null
# Rebuild completion cacherm -f ~/.zcompdump && compinitCompletions outdated after upgrade
Section titled “Completions outdated after upgrade”When you upgrade sql-splitter, new commands or flags won’t appear until you regenerate completions:
# Regenerate for your shell (example: zsh)sql-splitter completions zsh > ~/.oh-my-zsh/completions/_sql-splittersource ~/.zshrcPermission denied
Section titled “Permission denied”For system-wide installation, use sudo:
sudo sql-splitter completions bash > /etc/bash_completion.d/sql-splitterOr use user-only installation (recommended) which doesn’t require elevated permissions.
PowerShell profile doesn’t exist
Section titled “PowerShell profile doesn’t exist”Create the profile file before appending:
if (!(Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force}sql-splitter completions powershell >> $PROFILESee Also
Section titled “See Also”- Installation - Initial setup