Skip to content

Commit b70cc92

Browse files
committed
feat(completion): add zstyle verbose option for zsh completion
Add zstyle verbose option to customize Zsh completion display: - `verbose=true` (default): show task descriptions - `verbose=false`: show only task names Usage: zstyle ':completion:*:*:task:*' verbose false
1 parent e0d6b71 commit b70cc92

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

completion/zsh/_task

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

4343
scripts=()
44+
45+
# Read zstyle verbose option (default = true via -T)
46+
local show_desc
47+
zstyle -T ":completion:${curcontext}:" verbose && show_desc=true || show_desc=false
48+
4449
for item in "${(@)${(f)output}[2,-1]#\* }"; do
4550
task="${item%%:[[:space:]]*}"
46-
desc="${item##[^[:space:]]##[[:space:]]##}"
47-
scripts+=( "${task//:/\\:}:$desc" )
51+
52+
if [[ "$show_desc" == "true" ]]; then
53+
local desc="${item##[^[:space:]]##[[:space:]]##}"
54+
scripts+=( "${task//:/\\:}:$desc" )
55+
else
56+
scripts+=( "$task" )
57+
fi
4858
done
49-
_describe 'Task to run' scripts
59+
60+
if [[ "$show_desc" == "true" ]]; then
61+
_describe 'Task to run' scripts
62+
else
63+
compadd -Q -a scripts
64+
fi
5065
}
5166

5267
_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)