mirror of
https://github.com/zsh-users/zsh-completions.git
synced 2026-12-03 22:48:48 +08:00
0003eb0fb61e9a56f1cdcc87aed60dd249e29019
_cmake_generator_options removes the words before "--" so that make's or ninja's completion only sees the native build tool arguments, but it was written as `shift (( $2 - 1 )) words`. Without the `$`, `(( $2 - 1 ))` is a glob pattern, not arithmetic. The completion system turns on nullglob, so the pattern expands to nothing and shift removes only one word, while CURRENT is still moved back by $2 - 1. The build tool's completion then looks at the wrong word. For example `cmake --build build -- -t <Tab>` offered cmake options or ninja targets instead of ninja's subtools, `-C <Tab>` offered ninja targets instead of directories, and with Makefiles `-f <Tab>` mixed make targets and variables into the file list.
zsh-completions

Additional completion definitions for Zsh.
This project aims at gathering/developing new completion scripts that are not available in Zsh yet. The scripts may be contributed to the Zsh project when stable enough.
Usage
Using packages
| System | Package |
|---|---|
| Debian / Ubuntu | zsh-completions OBS repository |
| Fedora / CentOS / RHEL / Scientific Linux | zsh-completions OBS repository |
| OpenSUSE / SLE | zsh-completions OBS repository |
| Arch Linux / Manjaro / Antergos / Hyperbola | zsh-completions, zsh-completions-git |
| Gentoo / Funtoo | app-shells/zsh-completions |
| NixOS | zsh-completions |
| Void Linux | zsh-completions |
| Slackware | Slackbuilds |
| macOS | homebrew, MacPorts |
| NetBSD | pkgsrc |
| FreeBSD | shells/zsh-completions |
Using zsh frameworks
antigen
Add antigen bundle zsh-users/zsh-completions to your ~/.zshrc.
oh-my-zsh
To avoid issues with redundant .zcompdump cache generation (see #603), do not load zsh-completions as a standard plugin.
Instead, follow this optimized approach:
- Clone the repository into your custom plugins directory:
git clone https://github.com/zsh-users/zsh-completions.git \
${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions
- Update your
~/.zshrcconfiguration before sourcing oh-my-zsh:
fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src
autoload -U compinit && compinit
source "$ZSH/oh-my-zsh.sh"
This prevents compinit from being called twice and significantly improves shell startup time.
zinit
Add zinit light zsh-users/zsh-completions to your ~/.zshrc.
Manual installation
- Clone the repository:
git clone https://github.com/zsh-users/zsh-completions.git
- Include the directory in your
$fpath, for example by adding in~/.zshrc:
fpath=(path/to/zsh-completions/src $fpath)
- You may have to force rebuild
zcompdump:
rm -f ~/.zcompdump; compinit
Contributing
Contributions are welcome, see CONTRIBUTING.
License
Completions use the Zsh license, unless explicitly mentioned in the file header.
See LICENSE for more information.
Languages
Shell
94.7%
Python
4.3%
Emacs Lisp
1%