Shell Completion
leaf can automatically install completion scripts for your shell to make it easier to navigate files and flags.
Installation
Run the following command to detect your current shell and install the appropriate completion script:
leaf --auto-complete
Supported Shells
- Bash: Adds a source line to your
~/.bashrc. - Zsh: Adds a source line to your
~/.zshrc. - Fish: Installs the script to
~/.config/fish/completions/leaf.fish. - PowerShell: Adds a source line to your PowerShell profile (Windows only).
Manual Activation
After running the command, you may need to restart your terminal or source your configuration file for the changes to take effect:
# For Zsh
source ~/.zshrc
# For Bash
source ~/.bashrc
Targeted Installation
You can specify a shell explicitly instead of relying on auto-detection:
leaf --auto-complete bash
leaf --auto-complete zsh
leaf --auto-complete fish
leaf --auto-complete powershell
Script Dump
To print the completion script to stdout without installing it:
# Dump for auto-detected shell
leaf --auto-complete dump
# Dump for a specific shell
leaf --auto-complete bash:dump
leaf --auto-complete zsh:dump
# Save to a file
leaf --auto-complete bash:dump > leaf-completion.bash
Features
Once installed, you can use the Tab key to:
- Auto-complete filenames and paths.
- List and complete available flags like
--theme,--watch, or--editor. - Suggest available themes and supported editors.