Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tree-sitter/tree-sitter/llms.txt

Use this file to discover all available pages before exploring further.

The complete command generates a completion script for your shell. This enables autocompletion for the tree-sitter CLI.
tree-sitter complete --shell <SHELL>
Aliases: comp

Options

--shell
shell
required
The shell for which to generate the completion script.Supported values:
  • bash
  • elvish
  • fish
  • powershell (or power-shell)
  • zsh
  • nushell

Installation by Shell

Bash

Add to your ~/.bashrc:
eval "$(tree-sitter complete --shell bash)"
Or generate and save the completion script:
tree-sitter complete --shell bash > ~/.local/share/bash-completion/completions/tree-sitter

Zsh

Add to your ~/.zshrc:
eval "$(tree-sitter complete --shell zsh)"
Or save to a file in your fpath:
tree-sitter complete --shell zsh > ~/.zsh/completions/_tree-sitter
Then add to your ~/.zshrc before compinit:
fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit

Fish

Save to the Fish completions directory:
tree-sitter complete --shell fish > ~/.config/fish/completions/tree-sitter.fish

PowerShell

Add to your PowerShell profile:
tree-sitter complete --shell powershell | Out-String | Invoke-Expression
To find your profile location:
$PROFILE

Elvish

Add to your ~/.elvish/rc.elv:
eval (tree-sitter complete --shell elvish | slurp)

Nushell

Add to your Nushell config:
tree-sitter complete --shell nushell > ~/.config/nushell/completions/tree-sitter.nu
Then source it in your config.nu:
source ~/.config/nushell/completions/tree-sitter.nu

Examples

Generate Bash Completions

tree-sitter complete --shell bash

Generate Zsh Completions

tree-sitter complete --shell zsh

Generate Fish Completions

tree-sitter complete --shell fish

Save to File

tree-sitter complete --shell bash > tree-sitter-completions.bash

Features

Once installed, you can:
  • Tab-complete command names:
    tree-sitter g<TAB> tree-sitter generate
    
  • Tab-complete option names:
    tree-sitter generate --a<TAB> tree-sitter generate --abi
    
  • See available options:
    tree-sitter parse --<TAB>
    # Shows: --paths, --grammar-path, --lib-path, etc.
    

Troubleshooting

Completions Not Working

  1. Verify the completion script was loaded:
    # For bash
    complete -p tree-sitter
    
    # For zsh
    which _tree-sitter
    
  2. Restart your shell or source your config:
    # Bash
    source ~/.bashrc
    
    # Zsh
    source ~/.zshrc
    
  3. Check file permissions:
    ls -l ~/.local/share/bash-completion/completions/tree-sitter
    

Wrong Completions

If completions are outdated:
  1. Regenerate the completion script
  2. Restart your shell
  3. Clear any completion cache if applicable