mirror of
https://github.com/mudler/LocalAI
synced 2026-04-21 13:27:21 +00:00
feat: add shell completion support for bash, zsh, and fish - Add core/cli/completion.go with dynamic completion script generation - Add core/cli/completion_test.go with unit tests - Modify cmd/local-ai/main.go to support completion command - Modify core/cli/cli.go to add Completion subcommand - Add docs/content/features/shell-completion.md with installation instructions The completion scripts are generated dynamically from the Kong CLI model, so they automatically include all commands, subcommands, and flags. Co-authored-by: localai-bot <localai-bot@noreply.github.com>
87 lines
1.7 KiB
Markdown
87 lines
1.7 KiB
Markdown
+++
|
|
disableToc = false
|
|
title = "Shell Completion"
|
|
weight = 18
|
|
url = "/features/shell-completion/"
|
|
+++
|
|
|
|
LocalAI provides shell completion support for **bash**, **zsh**, and **fish** shells. Once installed, tab completion works for all CLI commands, subcommands, and flags.
|
|
|
|
## Generating Completion Scripts
|
|
|
|
Use the `completion` subcommand to generate a completion script for your shell:
|
|
|
|
```bash
|
|
local-ai completion bash
|
|
local-ai completion zsh
|
|
local-ai completion fish
|
|
```
|
|
|
|
## Installation
|
|
|
|
### Bash
|
|
|
|
Add the following to your `~/.bashrc`:
|
|
|
|
```bash
|
|
source <(local-ai completion bash)
|
|
```
|
|
|
|
Or install it system-wide:
|
|
|
|
```bash
|
|
local-ai completion bash > /etc/bash_completion.d/local-ai
|
|
```
|
|
|
|
### Zsh
|
|
|
|
Add the following to your `~/.zshrc`:
|
|
|
|
```zsh
|
|
source <(local-ai completion zsh)
|
|
```
|
|
|
|
Or install it to a completions directory:
|
|
|
|
```zsh
|
|
local-ai completion zsh > "${fpath[1]}/_local-ai"
|
|
```
|
|
|
|
If shell completions are not already enabled in your zsh environment, add the following to the beginning of your `~/.zshrc`:
|
|
|
|
```zsh
|
|
autoload -Uz compinit
|
|
compinit
|
|
```
|
|
|
|
### Fish
|
|
|
|
```fish
|
|
local-ai completion fish | source
|
|
```
|
|
|
|
Or install it permanently:
|
|
|
|
```fish
|
|
local-ai completion fish > ~/.config/fish/completions/local-ai.fish
|
|
```
|
|
|
|
## Usage
|
|
|
|
After installation, restart your shell or source your shell configuration file. Then type `local-ai` followed by a tab to see available commands:
|
|
|
|
```
|
|
$ local-ai <TAB>
|
|
run backends completion explorer models
|
|
federated sound-generation transcript tts util
|
|
```
|
|
|
|
Tab completion also works for subcommands and flags:
|
|
|
|
```
|
|
$ local-ai models <TAB>
|
|
install list
|
|
|
|
$ local-ai run --<TAB>
|
|
--address --backends-path --context-size --debug ...
|
|
```
|