|
|
|
@ -1,9 +1,6 @@ |
|
|
|
#compdef task |
|
|
|
#compdef task |
|
|
|
# zsh completion for taskwarrior |
|
|
|
|
|
|
|
# |
|
|
|
# |
|
|
|
# taskwarrior - a command line task list manager. |
|
|
|
# Copyright 2010 - 2015 Johannes Schlatow |
|
|
|
# |
|
|
|
|
|
|
|
# Copyright 2010 - 2011 Johannes Schlatow |
|
|
|
|
|
|
|
# Copyright 2009 P.C. Shyamshankar |
|
|
|
# Copyright 2009 P.C. Shyamshankar |
|
|
|
# |
|
|
|
# |
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy |
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy |
|
|
|
@ -30,31 +27,40 @@ typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers |
|
|
|
_task_projects=($(task _projects)) |
|
|
|
_task_projects=($(task _projects)) |
|
|
|
_task_tags=($(task _tags)) |
|
|
|
_task_tags=($(task _tags)) |
|
|
|
_task_ids=($(task _ids)) |
|
|
|
_task_ids=($(task _ids)) |
|
|
|
|
|
|
|
_task_zshids=( ${(f)"$(task _zshids)"} ) |
|
|
|
_task_config=($(task _config)) |
|
|
|
_task_config=($(task _config)) |
|
|
|
_task_columns=($(task _columns)) |
|
|
|
_task_columns=($(task _columns)) |
|
|
|
_task_modifiers=( |
|
|
|
_task_modifiers=( |
|
|
|
'before' \ |
|
|
|
'before' \ |
|
|
|
'after' \ |
|
|
|
'after' \ |
|
|
|
'none' \ |
|
|
|
'none' \ |
|
|
|
'any' \ |
|
|
|
'any' \ |
|
|
|
'is' \ |
|
|
|
'is' \ |
|
|
|
'isnt' \ |
|
|
|
'isnt' \ |
|
|
|
'has' \ |
|
|
|
'has' \ |
|
|
|
'hasnt' \ |
|
|
|
'hasnt' \ |
|
|
|
'startswith' \ |
|
|
|
'startswith' \ |
|
|
|
'endswith' \ |
|
|
|
'endswith' \ |
|
|
|
'word' \ |
|
|
|
'word' \ |
|
|
|
'noword' |
|
|
|
'noword' |
|
|
|
) |
|
|
|
) |
|
|
|
_task_conjunctions=( |
|
|
|
_task_conjunctions=( |
|
|
|
'and' \ |
|
|
|
'and' \ |
|
|
|
'or' \ |
|
|
|
'or' \ |
|
|
|
'xor' \ |
|
|
|
'xor' \ |
|
|
|
'\)' |
|
|
|
'\)' \ |
|
|
|
'\(' |
|
|
|
'\(' \ |
|
|
|
|
|
|
|
'<' \ |
|
|
|
|
|
|
|
'<=' \ |
|
|
|
|
|
|
|
'=' \ |
|
|
|
|
|
|
|
'!=' \ |
|
|
|
|
|
|
|
'>=' \ |
|
|
|
|
|
|
|
'>' |
|
|
|
) |
|
|
|
) |
|
|
|
_task_cmds=($(task _commands)) |
|
|
|
_task_cmds=($(task _commands; task _aliases)) |
|
|
|
_task_zshcmds=( ${(f)"$(task _zshcommands)"} ) |
|
|
|
_task_zshcmds=( ${(f)"$(task _zshcommands)"} sentinel:sentinel:sentinel ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_task_aliases=($(task _aliases)) |
|
|
|
|
|
|
|
|
|
|
|
_task() { |
|
|
|
_task() { |
|
|
|
_arguments -s -S \ |
|
|
|
_arguments -s -S \ |
|
|
|
@ -68,110 +74,130 @@ word=$'[^\0]#\0' |
|
|
|
# priorities |
|
|
|
# priorities |
|
|
|
local -a task_priorities |
|
|
|
local -a task_priorities |
|
|
|
_regex_words values 'task priorities' \ |
|
|
|
_regex_words values 'task priorities' \ |
|
|
|
'H:High' \ |
|
|
|
'H:High' \ |
|
|
|
'M:Middle' \ |
|
|
|
'M:Middle' \ |
|
|
|
'L:Low' |
|
|
|
'L:Low' |
|
|
|
task_priorities=("$reply[@]") |
|
|
|
task_priorities=("$reply[@]") |
|
|
|
|
|
|
|
|
|
|
|
# projects |
|
|
|
# projects |
|
|
|
local -a task_projects |
|
|
|
local -a task_projects |
|
|
|
task_projects=( |
|
|
|
task_projects=( |
|
|
|
/"$word"/ |
|
|
|
/"$word"/ |
|
|
|
":values:task projects:compadd -a _task_projects" |
|
|
|
":values:task projects:compadd -a _task_projects" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
local -a _task_dates |
|
|
|
local -a _task_dates |
|
|
|
_regex_words values 'task dates' \ |
|
|
|
_regex_words values 'task dates' \ |
|
|
|
'tod*ay:Today' \ |
|
|
|
'tod*ay:Today' \ |
|
|
|
'yes*terday:Yesterday' \ |
|
|
|
'yes*terday:Yesterday' \ |
|
|
|
'tom*orrow:Tomorrow' \ |
|
|
|
'tom*orrow:Tomorrow' \ |
|
|
|
'sow:Start of week' \ |
|
|
|
'sow:Start of week' \ |
|
|
|
'soww:Start of work week' \ |
|
|
|
'soww:Start of work week' \ |
|
|
|
'socw:Start of calendar week' \ |
|
|
|
'socw:Start of calendar week' \ |
|
|
|
'som:Start of month' \ |
|
|
|
'som:Start of month' \ |
|
|
|
'soy:Start of year' \ |
|
|
|
'soq:Start of quarter' \ |
|
|
|
'eow:End of week' \ |
|
|
|
'soy:Start of year' \ |
|
|
|
'eoww:End of work week' \ |
|
|
|
'eow:End of week' \ |
|
|
|
'eocw:End of calendar week' \ |
|
|
|
'eoww:End of work week' \ |
|
|
|
'eom:End of month' \ |
|
|
|
'eocw:End of calendar week' \ |
|
|
|
'eoy:End of year' \ |
|
|
|
'eom:End of month' \ |
|
|
|
'mon:Monday' \ |
|
|
|
'eoq:End of quarter' \ |
|
|
|
'tue:Tuesday'\ |
|
|
|
'eoy:End of year' \ |
|
|
|
'wed:Wednesday' \ |
|
|
|
'mon:Monday' \ |
|
|
|
'thu:Thursday' \ |
|
|
|
'tue:Tuesday'\ |
|
|
|
'fri:Friday' \ |
|
|
|
'wed:Wednesday' \ |
|
|
|
'sat:Saturday' \ |
|
|
|
'thu:Thursday' \ |
|
|
|
'sun:Sunday' |
|
|
|
'fri:Friday' \ |
|
|
|
|
|
|
|
'sat:Saturday' \ |
|
|
|
|
|
|
|
'sun:Sunday' \ |
|
|
|
|
|
|
|
'good*friday:Good Friday' \ |
|
|
|
|
|
|
|
'easter:Easter' \ |
|
|
|
|
|
|
|
'eastermonday:Easter Monday' \ |
|
|
|
|
|
|
|
'ascension:Ascension' \ |
|
|
|
|
|
|
|
'pentecost:Pentecost' \ |
|
|
|
|
|
|
|
'midsommar:Midsommar' \ |
|
|
|
|
|
|
|
'midsommarafton:Midsommarafton' \ |
|
|
|
|
|
|
|
'later:Later' \ |
|
|
|
|
|
|
|
'someday:Some Day' |
|
|
|
_task_dates=("$reply[@]") |
|
|
|
_task_dates=("$reply[@]") |
|
|
|
|
|
|
|
|
|
|
|
local -a _task_reldates |
|
|
|
local -a _task_reldates |
|
|
|
_regex_words values 'task reldates' \ |
|
|
|
_regex_words values 'task reldates' \ |
|
|
|
'hrs:n hours' \ |
|
|
|
'hrs:n hours' \ |
|
|
|
'day:n days' \ |
|
|
|
'day:n days' \ |
|
|
|
'1st:first' \ |
|
|
|
'1st:first' \ |
|
|
|
'2nd:second' \ |
|
|
|
'2nd:second' \ |
|
|
|
'3rd:third' \ |
|
|
|
'3rd:third' \ |
|
|
|
'th:4th, 5th, etc.' \ |
|
|
|
'th:4th, 5th, etc.' \ |
|
|
|
'wks:weeks' |
|
|
|
'wks:weeks' |
|
|
|
_task_reldates=("$reply[@]") |
|
|
|
_task_reldates=("$reply[@]") |
|
|
|
|
|
|
|
|
|
|
|
task_dates=( |
|
|
|
task_dates=( |
|
|
|
\( "$_task_dates[@]" \| |
|
|
|
\( "$_task_dates[@]" \| |
|
|
|
\( /$'[0-9][0-9]#'/- \( "$_task_reldates[@]" \) \) |
|
|
|
\( /$'[0-9][0-9]#'/- \( "$_task_reldates[@]" \) \) |
|
|
|
\) |
|
|
|
\) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local -a task_zshids |
|
|
|
|
|
|
|
_regex_words values 'task IDs' $_task_zshids |
|
|
|
|
|
|
|
task_zshids=("$reply[@]") |
|
|
|
|
|
|
|
|
|
|
|
_regex_words values 'task frequencies' \ |
|
|
|
_regex_words values 'task frequencies' \ |
|
|
|
'daily:Every day' \ |
|
|
|
'daily:Every day' \ |
|
|
|
'day:Every day' \ |
|
|
|
'day:Every day' \ |
|
|
|
'weekdays:Every day skipping weekend days' \ |
|
|
|
'weekdays:Every day skipping weekend days' \ |
|
|
|
'weekly:Every week' \ |
|
|
|
'weekly:Every week' \ |
|
|
|
'biweekly:Every two weeks' \ |
|
|
|
'biweekly:Every two weeks' \ |
|
|
|
'fortnight:Every two weeks' \ |
|
|
|
'fortnight:Every two weeks' \ |
|
|
|
+ 'monthly:Every month' \ |
|
|
|
'monthly:Every month' \ |
|
|
|
'quarterly:Every three months' \ |
|
|
|
'quarterly:Every three months' \ |
|
|
|
'semiannual:Every six months' \ |
|
|
|
'semiannual:Every six months' \ |
|
|
|
'annual:Every year' \ |
|
|
|
'annual:Every year' \ |
|
|
|
'yearly:Every year' \ |
|
|
|
'yearly:Every year' \ |
|
|
|
'biannual:Every two years' \ |
|
|
|
'biannual:Every two years' \ |
|
|
|
'biyearly:Every two years' |
|
|
|
'biyearly:Every two years' |
|
|
|
_task_freqs=("$reply[@]") |
|
|
|
_task_freqs=("$reply[@]") |
|
|
|
|
|
|
|
|
|
|
|
local -a _task_frequencies |
|
|
|
local -a _task_frequencies |
|
|
|
_regex_words values 'task frequencies' \ |
|
|
|
_regex_words values 'task frequencies' \ |
|
|
|
'd:days' \ |
|
|
|
'd:days' \ |
|
|
|
'w:weeks' \ |
|
|
|
'w:weeks' \ |
|
|
|
'q:quarters' \ |
|
|
|
'q:quarters' \ |
|
|
|
'y:years' |
|
|
|
'y:years' |
|
|
|
_task_frequencies=("$reply[@]") |
|
|
|
_task_frequencies=("$reply[@]") |
|
|
|
|
|
|
|
|
|
|
|
task_freqs=( |
|
|
|
task_freqs=( |
|
|
|
\( "$_task_freqs[@]" \| |
|
|
|
\( "$_task_freqs[@]" \| |
|
|
|
\( /$'[0-9][0-9]#'/- \( "$_task_frequencies[@]" \) \) |
|
|
|
\( /$'[0-9][0-9]#'/- \( "$_task_frequencies[@]" \) \) |
|
|
|
\) |
|
|
|
\) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# attributes |
|
|
|
# attributes |
|
|
|
local -a task_attributes |
|
|
|
local -a task_attributes |
|
|
|
_regex_words -t ':' default 'task attributes' \ |
|
|
|
_regex_words -t ':' default 'task attributes' \ |
|
|
|
'pro*ject:Project name:$task_projects' \ |
|
|
|
'des*cription:Task description text' \ |
|
|
|
'du*e:Due date:$task_dates' \ |
|
|
|
'status:Status of task - pending, completed, deleted, waiting' \ |
|
|
|
'wa*it:Date until task becomes pending:$task_dates' \ |
|
|
|
'pro*ject:Project name:$task_projects' \ |
|
|
|
're*cur:Recurrence frequency:$task_freqs' \ |
|
|
|
'pri*ority:priority:$task_priorities' \ |
|
|
|
'pri*ority:priority:$task_priorities' \ |
|
|
|
'du*e:Due date:$task_dates' \ |
|
|
|
'un*til:Recurrence end date:$task_dates' \ |
|
|
|
're*cur:Recurrence frequency:$task_freqs' \ |
|
|
|
'fg:Foreground color' \ |
|
|
|
'un*til:Expiration date:$task_dates' \ |
|
|
|
'bg:Background color' \ |
|
|
|
'li*mit:Desired number of rows in report' \ |
|
|
|
'li*mit:Desired number of rows in report' |
|
|
|
'wa*it:Date until task becomes pending:$task_dates' \ |
|
|
|
|
|
|
|
'ent*ry:Date task was created:$task_dates' \ |
|
|
|
|
|
|
|
'end:Date task was completed/deleted:$task_dates' \ |
|
|
|
|
|
|
|
'st*art:Date task was started:$task_dates' \ |
|
|
|
|
|
|
|
'sc*heduled:Date task is scheduled to start:$task_dates' \ |
|
|
|
|
|
|
|
'dep*ends:Other tasks that this task depends upon:$task_zshids' |
|
|
|
task_attributes=("$reply[@]") |
|
|
|
task_attributes=("$reply[@]") |
|
|
|
|
|
|
|
|
|
|
|
args=( |
|
|
|
args=( |
|
|
|
\( "$task_attributes[@]" \| |
|
|
|
\( "$task_attributes[@]" \| |
|
|
|
\( /'(project|due|wait|recur|priority|until|fg|bg|limit).'/- \( /$'[^:]#:'/ ":default:modifiers:compadd -S ':' -a _task_modifiers" \) \) \| |
|
|
|
\( /'(project|description|status|entry|end|start|scheduled|depends|due|wait|recur|priority|until|limit).'/- \( /$'[^:]#:'/ ":default:modifiers:compadd -S ':' -a _task_modifiers" \) \) \| |
|
|
|
\( /'(rc).'/- \( /$'[^:]#:'/ ":arguments:config:compadd -S ':' -a _task_config" \) \) \| |
|
|
|
\( /'(rc).'/- \( /$'[^:]#:'/ ":arguments:config:compadd -S ':' -a _task_config" \) \) \| |
|
|
|
\( /'(+|-)'/- \( /"$word"/ ":values:remove tag:compadd -a _task_tags" \) \) \| |
|
|
|
\( /'(+|-)'/- \( /"$word"/ ":values:remove tag:compadd -a _task_tags" \) \) \| |
|
|
|
\( /"$word"/ \) |
|
|
|
\( /"$word"/ \) |
|
|
|
\) \# |
|
|
|
\) \# |
|
|
|
) |
|
|
|
) |
|
|
|
_regex_arguments _task_attributes "${args[@]}" |
|
|
|
_regex_arguments _task_attributes "${args[@]}" |
|
|
|
|
|
|
|
|
|
|
|
@ -180,43 +206,50 @@ _regex_arguments _task_attributes "${args[@]}" |
|
|
|
# filter completion |
|
|
|
# filter completion |
|
|
|
(( $+functions[_task_filter] )) || |
|
|
|
(( $+functions[_task_filter] )) || |
|
|
|
_task_filter() { |
|
|
|
_task_filter() { |
|
|
|
_task_attributes "$@" |
|
|
|
_task_attributes "$@" |
|
|
|
|
|
|
|
|
|
|
|
# TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command |
|
|
|
|
|
|
|
_describe -t default 'task conjunctions' _task_conjunctions |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# merge completion |
|
|
|
|
|
|
|
(( $+functions[_task_merge] )) || |
|
|
|
|
|
|
|
_task_merge() { |
|
|
|
|
|
|
|
# TODO match URIs in .taskrc |
|
|
|
|
|
|
|
_files |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# push completion |
|
|
|
|
|
|
|
(( $+functions[_task_push] )) || |
|
|
|
|
|
|
|
_task_push() { |
|
|
|
|
|
|
|
# TODO match URIs in .taskrc |
|
|
|
|
|
|
|
_files |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# pull completion |
|
|
|
# TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command |
|
|
|
(( $+functions[_task_pull] )) || |
|
|
|
_describe -t default 'task conjunctions' _task_conjunctions |
|
|
|
_task_pull() { |
|
|
|
|
|
|
|
# TODO match URIs in .taskrc |
|
|
|
|
|
|
|
_files |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# execute completion |
|
|
|
# execute completion |
|
|
|
(( $+functions[_task_execute] )) || |
|
|
|
(( $+functions[_task_execute] )) || |
|
|
|
_task_execute() { |
|
|
|
_task_execute() { |
|
|
|
_files |
|
|
|
_files |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# id-only completion |
|
|
|
# id-only completion |
|
|
|
(( $+functions[_task_id] )) || |
|
|
|
(( $+functions[_task_id] )) || |
|
|
|
_task_id() { |
|
|
|
_task_id() { |
|
|
|
_describe -t values 'task IDs' _task_zshids |
|
|
|
_describe -t values 'task IDs' _task_zshids |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# subcommand-only function |
|
|
|
|
|
|
|
(( $+functions[_task_subcommands] )) || |
|
|
|
|
|
|
|
_task_subcommands() { |
|
|
|
|
|
|
|
local -a subcommands |
|
|
|
|
|
|
|
local _zshcmd |
|
|
|
|
|
|
|
local cmd category desc |
|
|
|
|
|
|
|
local lastcategory='' |
|
|
|
|
|
|
|
# The list is sorted by category, in the right order. |
|
|
|
|
|
|
|
for _zshcmd in "$_task_zshcmds[@]"; do |
|
|
|
|
|
|
|
# Parse out the three fields |
|
|
|
|
|
|
|
cmd=${_zshcmd%%:*} |
|
|
|
|
|
|
|
category=${${_zshcmd#*:}%%:*} |
|
|
|
|
|
|
|
desc=${_zshcmd#*:*:} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Present each category as soon as the first entry in the *next* category |
|
|
|
|
|
|
|
# is seen. |
|
|
|
|
|
|
|
if [[ $category != $lastcategory && -n $lastcategory ]]; then |
|
|
|
|
|
|
|
_describe -t ${lastcategory}-commands "task ${lastcategory} command" subcommands |
|
|
|
|
|
|
|
subcommands=() |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Log the subcommand; we will process it in some future iteration. |
|
|
|
|
|
|
|
subcommands+=( "$cmd:$desc" ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lastcategory=$category |
|
|
|
|
|
|
|
done |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
## first level completion => task sub-command completion |
|
|
|
## first level completion => task sub-command completion |
|
|
|
@ -224,27 +257,28 @@ _task_id() { |
|
|
|
_task_default() { |
|
|
|
_task_default() { |
|
|
|
local cmd ret=1 |
|
|
|
local cmd ret=1 |
|
|
|
|
|
|
|
|
|
|
|
integer i=1 |
|
|
|
integer i=1 |
|
|
|
while (( i < $#words )) |
|
|
|
while (( i < $#words )) |
|
|
|
do |
|
|
|
do |
|
|
|
cmd="${_task_cmds[(r)$words[$i]]}" |
|
|
|
cmd="${_task_cmds[(r)$words[$i]]}" |
|
|
|
if (( $#cmd )); then |
|
|
|
if (( $#cmd )); then |
|
|
|
_call_function ret _task_${cmd} || |
|
|
|
_call_function ret _task_${cmd} || |
|
|
|
_call_function ret _task_filter || |
|
|
|
_call_function ret _task_filter || |
|
|
|
_message "No command remaining." |
|
|
|
_message "No command remaining." |
|
|
|
return ret |
|
|
|
return ret |
|
|
|
fi |
|
|
|
fi |
|
|
|
(( i++ )) |
|
|
|
(( i++ )) |
|
|
|
done |
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
# update IDs |
|
|
|
# update IDs |
|
|
|
_task_zshids=( ${(f)"$(task _zshids)"} ) |
|
|
|
_task_zshids=( ${(f)"$(task _zshids)"} ) |
|
|
|
|
|
|
|
|
|
|
|
_describe -t commands 'task command' _task_zshcmds |
|
|
|
_task_subcommands |
|
|
|
_describe -t values 'task IDs' _task_zshids |
|
|
|
_describe -t tasks 'task IDs' _task_zshids |
|
|
|
_call_function ret _task_filter |
|
|
|
_describe -t aliases 'task aliases' _task_aliases |
|
|
|
|
|
|
|
_call_function ret _task_filter |
|
|
|
return ret |
|
|
|
|
|
|
|
|
|
|
|
return ret |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_task |
|
|
|
_task "$@" |
|
|
|
|