mirror of
https://github.com/go-task/task.git
synced 2025-12-24 23:49:24 +01:00
feat(completion): add zstyle verbose option for zsh completion (#2571)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user