From d827a9156ecdb96396316393d3cbd54fb38f6895 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sat, 11 Feb 2023 21:51:50 -0500 Subject: [PATCH] Add documentation on enabling autocompletion (#2791) --- README.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 969b518cbf..c34bc17320 100644 --- a/README.md +++ b/README.md @@ -620,7 +620,7 @@ configuration. See the [`isort` documentation](https://pycqa.github.io/isort/docs/configuration/action_comments.html) for more. -#### Exit codes +### Exit codes By default, Ruff exits with the following status codes: @@ -639,6 +639,25 @@ Ruff supports two command-line flags that alter its exit code behavior: `--exit-non-zero-on-fix` can result in a non-zero exit code even if no violations remain after autofixing. +### Autocompletion + +Ruff supports autocompletion for most shells. A shell-specific completion script can be generated +by `ruff completion `, where `` is one of `bash`, `elvish`, `fig`, `fish`, +`powershell`, or `zsh`. + +The exact steps required to enable autocompletion will vary by shell. For example instructions, +see the [Poetry](https://python-poetry.org/docs/#enable-tab-completion-for-bash-fish-or-zsh) or +[ripgrep](https://github.com/BurntSushi/ripgrep/blob/master/FAQ.md#complete) documentation. + +As an example: to enable autocompletion for Zsh, run +`ruff generate-shell-completion zsh > ~/.zfunc/_ruff`. Then add the following line to your +`~/.zshrc` file, if they're not already present: + +```zsh +fpath+=~/.zfunc +autoload -Uz compinit && compinit +``` + ## Supported Rules