feat(completion): add zstyle verbose option for zsh completion (#2571)

This commit is contained in:
Valentin Maerten
2025-12-18 08:35:56 +01:00
committed by GitHub
parent 4ec6c453bd
commit b710259bfa
3 changed files with 30 additions and 3 deletions

View File

@@ -52,6 +52,8 @@
using `for` loops in Taskfiles (#2576 by @vmaerten).
- Added `--remote-cache-dir` flag and `remote.cache-dir` taskrc option to
customize the cache directory for Remote Taskfiles (#2572 by @vmaerten).
- Zsh completion now supports zstyle verbose option to show or hide task
descriptions (#2571 by @vmaerten).
## v3.45.5 - 2025-11-11

View File

@@ -45,12 +45,27 @@ function __task_list() {
(( enabled )) || return 0
scripts=()
# Read zstyle verbose option (default = true via -T)
local show_desc
zstyle -T ":completion:${curcontext}:" verbose && show_desc=true || show_desc=false
for item in "${(@)${(f)output}[2,-1]#\* }"; do
task="${item%%:[[:space:]]*}"
desc="${item##[^[:space:]]##[[:space:]]##}"
scripts+=( "${task//:/\\:}:$desc" )
if [[ "$show_desc" == "true" ]]; then
local desc="${item##[^[:space:]]##[[:space:]]##}"
scripts+=( "${task//:/\\:}:$desc" )
else
scripts+=( "$task" )
fi
done
_describe 'Task to run' scripts
if [[ "$show_desc" == "true" ]]; then
_describe 'Task to run' scripts
else
compadd -Q -a scripts
fi
}
_task() {

View File

@@ -384,3 +384,13 @@ task --completion fish > ~/.config/fish/completions/task.fish
```
:::
### Zsh customization
The Zsh completion supports the standard `verbose` zstyle to control whether task
descriptions are shown. By default, descriptions are displayed. To show only task
names without descriptions, add this to your `~/.zshrc` (after the completion is loaded):
```shell
zstyle ':completion:*:*:task:*' verbose false
```