## CHANGES - Add one-liner curl install for completions - Support downloading completions when files missing locally - Add dry-run option for preview changes - Enable custom download source via environment variable - Create temp directory for downloaded completion files - Add automatic cleanup of temporary files - Update documentation with new installation methods
4.9 KiB
Shell Completions for Fabric
Fabric comes with shell completion support for Zsh, Bash, and Fish shells. These completions provide intelligent tab-completion for commands, flags, patterns, models, contexts, and more.
Quick Setup (Automated)
You can install completions without cloning the repo:
# No-clone install (Zsh/Bash/Fish supported)
curl -fsSL https://raw.githubusercontent.com/danielmiessler/Fabric/refs/heads/main/completions/setup-completions.sh | sh
# Optional: dry-run first
curl -fsSL https://raw.githubusercontent.com/danielmiessler/Fabric/refs/heads/main/completions/setup-completions.sh | sh -s -- --dry-run
# Optional: override the download source
FABRIC_COMPLETIONS_BASE_URL="https://raw.githubusercontent.com/danielmiessler/Fabric/refs/heads/main/completions" \
sh -c "$(curl -fsSL https://raw.githubusercontent.com/danielmiessler/Fabric/refs/heads/main/completions/setup-completions.sh)"
Or, if you have the repository locally:
# Run the automated setup script from a cloned repo
./completions/setup-completions.sh
# Or see what it would do first
./completions/setup-completions.sh --dry-run
The script will:
- Detect whether you have
fabricorfabric-aiinstalled - Detect your current shell (zsh, bash, or fish)
- Use your existing
$fpathdirectories (for zsh) or standard completion directories - Install the completion file with the correct name
- Provide instructions for enabling the completions
If the completion files aren't present locally (e.g., when running via curl), the script will automatically download them from GitHub.
For manual installation or troubleshooting, see the detailed instructions below.
Manual Installation
Zsh
-
Copy the completion file to a directory in your
$fpath:sudo cp completions/_fabric /usr/local/share/zsh/site-functions/ -
Important: If you installed fabric as
fabric-ai, create a symlink so completions work:sudo ln -s /usr/local/share/zsh/site-functions/_fabric /usr/local/share/zsh/site-functions/_fabric-ai -
Restart your shell or reload completions:
autoload -U compinit && compinit
Bash
-
Copy the completion file to a standard completion directory:
# System-wide installation sudo cp completions/fabric.bash /etc/bash_completion.d/ # Or user-specific installation mkdir -p ~/.local/share/bash-completion/completions/ cp completions/fabric.bash ~/.local/share/bash-completion/completions/fabric -
Important: If you installed fabric as
fabric-ai, create a symlink:# For system-wide installation sudo ln -s /etc/bash_completion.d/fabric.bash /etc/bash_completion.d/fabric-ai.bash # Or for user-specific installation ln -s ~/.local/share/bash-completion/completions/fabric ~/.local/share/bash-completion/completions/fabric-ai -
Restart your shell or source the completion:
source ~/.bashrc
Fish
-
Copy the completion file to Fish's completion directory:
mkdir -p ~/.config/fish/completions cp completions/fabric.fish ~/.config/fish/completions/ -
Important: If you installed fabric as
fabric-ai, create a symlink:ln -s ~/.config/fish/completions/fabric.fish ~/.config/fish/completions/fabric-ai.fish -
Fish will automatically load the completions (no restart needed).
Features
The completions provide intelligent suggestions for:
- Patterns: Tab-complete available patterns with
-por--pattern - Models: Tab-complete available models with
-mor--model - Contexts: Tab-complete contexts for context-related flags
- Sessions: Tab-complete sessions for session-related flags
- Strategies: Tab-complete available strategies
- Extensions: Tab-complete registered extensions
- Gemini Voices: Tab-complete TTS voices for
--voice - File paths: Smart file completion for attachment, output, and config options
- Flag completion: All available command-line flags and options
Alternative Installation Method
You can also source the completion files directly in your shell's configuration file:
- Zsh: Add to
~/.zshrc:source /path/to/fabric/completions/_fabric - Bash: Add to
~/.bashrc:source /path/to/fabric/completions/fabric.bash - Fish: The file-based installation method above is preferred for Fish
Troubleshooting
- If completions don't work, ensure the completion files have proper permissions
- For Zsh, verify that the completion directory is in your
$fpath - If you renamed the fabric binary, make sure to create the appropriate symlinks as described above
- Restart your shell after installation to ensure completions are loaded
The completion system dynamically queries the fabric command for current patterns, models, and other resources, so your completions will always be up-to-date with your fabric installation.