Skip to content

Commit b710259

Browse files
authored
feat(completion): add zstyle verbose option for zsh completion (#2571)
1 parent 4ec6c45 commit b710259

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
using `for` loops in Taskfiles (#2576 by @vmaerten).
5353
- Added `--remote-cache-dir` flag and `remote.cache-dir` taskrc option to
5454
customize the cache directory for Remote Taskfiles (#2572 by @vmaerten).
55+
- Zsh completion now supports zstyle verbose option to show or hide task
56+
descriptions (#2571 by @vmaerten).
5557

5658
## v3.45.5 - 2025-11-11
5759

completion/zsh/_task

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,27 @@ function __task_list() {
4545
(( enabled )) || return 0
4646

4747
scripts=()
48+
49+
# Read zstyle verbose option (default = true via -T)
50+
local show_desc
51+
zstyle -T ":completion:${curcontext}:" verbose && show_desc=true || show_desc=false
52+
4853
for item in "${(@)${(f)output}[2,-1]#\* }"; do
4954
task="${item%%:[[:space:]]*}"
50-
desc="${item##[^[:space:]]##[[:space:]]##}"
51-
scripts+=( "${task//:/\\:}:$desc" )
55+
56+
if [[ "$show_desc" == "true" ]]; then
57+
local desc="${item##[^[:space:]]##[[:space:]]##}"
58+
scripts+=( "${task//:/\\:}:$desc" )
59+
else
60+
scripts+=( "$task" )
61+
fi
5262
done
53-
_describe 'Task to run' scripts
63+
64+
if [[ "$show_desc" == "true" ]]; then
65+
_describe 'Task to run' scripts
66+
else
67+
compadd -Q -a scripts
68+
fi
5469
}
5570

5671
_task() {

website/src/docs/installation.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,3 +384,13 @@ task --completion fish > ~/.config/fish/completions/task.fish
384384
```
385385

386386
:::
387+
388+
### Zsh customization
389+
390+
The Zsh completion supports the standard `verbose` zstyle to control whether task
391+
descriptions are shown. By default, descriptions are displayed. To show only task
392+
names without descriptions, add this to your `~/.zshrc` (after the completion is loaded):
393+
394+
```shell
395+
zstyle ':completion:*:*:task:*' verbose false
396+
```

0 commit comments

Comments
 (0)