diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fd6550a79..8559f6fcb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/completion/zsh/_task b/completion/zsh/_task index 4b70aaccfd..c0703a09f4 100755 --- a/completion/zsh/_task +++ b/completion/zsh/_task @@ -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() { diff --git a/website/src/docs/installation.md b/website/src/docs/installation.md index 4a7e03bb37..19e4036f70 100644 --- a/website/src/docs/installation.md +++ b/website/src/docs/installation.md @@ -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 +```