From f974e33fa48908e7cb4f937b2a56cbc488b55004 Mon Sep 17 00:00:00 2001 From: "P.C. Shyamshankar" Date: Tue, 12 May 2009 18:58:27 +0800 Subject: [PATCH 1/3] Initial commit of zsh completion, completes only subcommands right now. Signed-off-by: Paul Beckingham --- completion/_task | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 completion/_task diff --git a/completion/_task b/completion/_task new file mode 100644 index 000000000..8344dad16 --- /dev/null +++ b/completion/_task @@ -0,0 +1,32 @@ +#compdef task +# zsh completion for task as of 1.6.0 +# P.C. Shyamshankar + +typeset -g _task_cmds +_task_cmds=(add append annotate completed description description delete undelete info start stop done undo projects tags summary 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 +} + From 9d2b2de49483504dfe94b74524b02f64d42c08c2 Mon Sep 17 00:00:00 2001 From: "P.C. Shyamshankar" Date: Fri, 15 May 2009 14:21:24 +0800 Subject: [PATCH 2/3] Updated completion for 1.7.0, dynamically getting subcommands from task. Signed-off-by: Paul Beckingham --- completion/_task | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/completion/_task b/completion/_task index 8344dad16..e53389ccb 100644 --- a/completion/_task +++ b/completion/_task @@ -1,9 +1,12 @@ #compdef task -# zsh completion for task as of 1.6.0 +# zsh completion for task # P.C. Shyamshankar typeset -g _task_cmds -_task_cmds=(add append annotate completed description description delete undelete info start stop done undo projects tags summary history ghistory next calendar active overdue stats import export color version help list long ls newest oldest) +_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 \ @@ -29,4 +32,3 @@ _task_commands() { return ret fi } - From 59bd54fd37d2076314844543012ea3e7ac03c9a4 Mon Sep 17 00:00:00 2001 From: "P.C. Shyamshankar" Date: Fri, 15 May 2009 14:34:16 +0800 Subject: [PATCH 3/3] Moved completion file to its own zsh subdirectory. Signed-off-by: Paul Beckingham --- completion/{ => zsh}/_task | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename completion/{ => zsh}/_task (100%) diff --git a/completion/_task b/completion/zsh/_task similarity index 100% rename from completion/_task rename to completion/zsh/_task