# How to Use the Completion Command in Kimi-CLI: Shell Setup Guide

> Master Kimi-CLI's completion command to generate and install shell tab-completion scripts. Streamline your workflow with effortless command auto-completion. Setup guide included.

- Repository: [Moonshot AI/kimi-cli](https://github.com/MoonshotAI/kimi-cli)
- Tags: how-to-guide
- Published: 2026-07-25

---

**The `completion` command in kimi-cli generates shell-specific tab-completion scripts that you can evaluate immediately or install permanently to enable auto-completion for Kimi-CLI commands and arguments.**

The **MoonshotAI/kimi-cli** repository includes a built-in `completion` sub-command that integrates with Typer's click-completion system to provide intelligent shell completions. This command outputs the appropriate completion script for your preferred shell (bash, zsh, fish, or PowerShell) to stdout, allowing you to configure your terminal environment for faster, more efficient command-line interaction with the Kimi AI assistant.

## Supported Shells and Basic Usage

The completion command supports four major shell environments. In [`src/kimi_cli/cli/__init__.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/cli/__init__.py), the Typer application registers this functionality (around line 45) to handle shell-specific script generation.

### Bash

For immediate use in the current session, evaluate the output directly:

```bash
eval "$(kimi completion bash)"

```

To install permanently, add the evaluation line to your `~/.bashrc` or place the generated script in `/etc/bash_completion.d/`:

```bash
echo 'eval "$(kimi completion bash)"' >> ~/.bashrc

```

### Zsh

Zsh users can enable completions instantly with:

```bash
eval "$(kimi completion zsh)"

```

For persistent configuration, append the command to `~/.zshrc` or save the script to a directory listed in your `$fpath`:

```bash
echo 'eval "$(kimi completion zsh)"' >> ~/.zshrc

```

### Fish

Fish shell handles completions through its dedicated completions directory:

```bash
kimi completion fish | source

```

To install permanently:

```bash
kimi completion fish > ~/.config/fish/completions/kimi.fish

```

### PowerShell

Windows PowerShell users can load completions for the current session:

```powershell
kimi completion powershell | Out-String | Invoke-Expression

```

To make the configuration permanent, append the output to your PowerShell profile:

```powershell
kimi completion powershell >> $PROFILE

```

## Command Reference and Help Options

The completion command includes built-in help documentation accessible via the `--help` flag. This displays available shell options and usage instructions:

```bash
kimi completion --help

```

**Key characteristics of the command:**
- **Output destination**: All completion scripts write to stdout, allowing you to pipe or redirect the output as needed
- **No arguments required**: The command requires a shell name argument (bash, zsh, fish, or powershell)
- **Typer integration**: The command is auto-generated by the Typer CLI framework's completion system

## Technical Implementation Details

The completion infrastructure spans several key files in the kimi-cli codebase:

**[`src/kimi_cli/cli/__init__.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/cli/__init__.py)** defines the main Typer application instance and registers the completion command through Typer's native completion support (configured with `add_completion=False` to manage registration manually).

**[`src/kimi_cli/cli/_lazy_group.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/cli/_lazy_group.py)** contains the lazy-loaded command group implementation that integrates click-completion functionality, ensuring completion scripts load efficiently without impacting CLI startup performance.

**[`src/kimi_cli/ui/shell/prompt.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/ui/shell/prompt.py)** leverages the completion system for interactive shell features, handling slash-command completions and real-time suggestion rendering in the terminal interface.

**[`src/kimi_cli/utils/file_filter.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/utils/file_filter.py)** provides the underlying file-filter logic that supports `@`-style file mention completions within the interactive shell environment.

**[`src/kimi_cli/ui/theme.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/ui/theme.py)** defines the color schemes and styling rules applied to completion menus displayed during interactive sessions.

## Summary

- The **`kimi completion`** command generates shell-specific tab-completion scripts for bash, zsh, fish, and PowerShell.
- Scripts output to **stdout**, allowing immediate evaluation with `eval` or persistent installation via shell configuration files.
- The command is implemented in **[`src/kimi_cli/cli/__init__.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/cli/__init__.py)** using Typer's click-completion integration.
- Related completion infrastructure resides in **[`_lazy_group.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/_lazy_group.py)**, **[`prompt.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/prompt.py)**, **[`file_filter.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/file_filter.py)**, and **[`theme.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/theme.py)**.
- Use **`kimi completion --help`** to view available shells and syntax options.

## Frequently Asked Questions

### How do I check which shells are supported by the completion command?

Run `kimi completion --help` to display the list of supported shells and basic usage instructions. The command currently supports bash, zsh, fish, and PowerShell as specified in the Typer CLI configuration.

### Why do I need to use `eval` with the completion command?

The `completion` command outputs the raw shell script to stdout rather than executing it directly. Using `eval "$(kimi completion bash)"` (or your specific shell) processes that output in the current shell context, immediately activating the completion features without writing files to disk.

### Where should I save the completion script for permanent use?

The location depends on your shell: add the `eval` line to `~/.bashrc` for Bash, `~/.zshrc` for Zsh, or save the Fish output to `~/.config/fish/completions/kimi.fish`. For system-wide installation on Linux, place bash completions in `/etc/bash_completion.d/`.

### Does the completion command support Windows Command Prompt (cmd.exe)?

No, the completion command specifically supports PowerShell on Windows platforms, along with bash, zsh, and fish on Unix-like systems. Command Prompt users should use PowerShell or manually configure aliases for kimi-cli functionality.