taskwarrior/completion/zsh/_task
P.C. Shyamshankar 59bd54fd37 Moved completion file to its own zsh subdirectory.
Signed-off-by: Paul Beckingham <paul@beckingham.net>
2009-05-16 07:14:10 +08:00

34 lines
1 KiB
Text

#compdef task
# zsh completion for task
# P.C. Shyamshankar
typeset -g _task_cmds
_task_cmds=($(task rubbish-command | sed -n -e 's/^\s\+task \(\w\+\) .*/\1/p' | grep -v ID))
# As of task 1.7.0,
# _task_cmds=(add append annotate completed edit duplicate delete undelete info start stop done undo projects tags summary timesheet history ghistory next calendar active overdue stats import export color version help list long ls newest oldest)
_task() {
_arguments -s -S \
"*::task command:_task_commands"
return 0
}
(( $+functions[_task_commands] )) ||
_task_commands() {
local cmd ret=1
if (( CURRENT == 1 )); then
_describe -t commands 'task command' _task_cmds
else
local curcontext="${curcontext}"
cmd="${_task_cmds[(r)$words[1]:*]%%:*}"
if (( $#cmd )); then
curcontext="${curcontext%:*:*}:task-${cmd}"
_call_function ret _task_${cmd} || _message "No command remaining."
else
_message "Unknown subcommand ${cmd}"
fi
return ret
fi
}