#compdef devtodo todo tda tde tdd tdr ## completion for devtodo 0.1.20 ## Daniel Friesel ## https://derf.homelinux.org/~derf/dotfiles/completion/_devtodo typeset -a arg_generic arg_add typeset -A arg_pair arg_desc typeset expl arg_add=( '-p[priority]:priority:_priority' '-g[parent item]:parent:_index' ) arg_generic=( '--remove[remove items]:index:_index' '--database[database file]:file:_files' '--global-database[global database file]:file:_files' '*--colour[item color]:color:_color' '--force-colour[force use of colors]' '--mono[no colors]' '--help[display help]' '--version[display version]' '--title[todo title]:string: ' '--date-format[strftime time formet]:time string: ' '*--format[define format]:format:_format' '*--use-format[output format]:format:_format' '--sort[sort database]:expression: ' '--paranoid[paranoid parmissions etc]' '--database-loaders[loader order]:database loader: ' '--backup[backup database]:count: ' '--timeout[display timeout]:seconds: ' '--purge[purge completed items]:days: ' ) arg_pair=( 'verbose' 'v' 'add' 'a' 'graft' 'g' 'link' 'l' 'reparent' 'R' 'priority' 'p' 'edit' 'e' 'done' 'd' 'not-done' 'D' 'global' 'G' 'TODO' 'T' 'all' 'A' 'filter' 'f' ) arg_desc=( 'verbose' '[be verbose]' 'add' '[add item]:item' 'graft' '[parent item]:parent:_index' 'link' '[link file into database]:database:_files' 'reparent' '[change item parent]:index:_index' 'priority' '[item priority]:priority:_priority' 'edit' '[edit item]:index:_index' 'done' '[mark as done]:index:_index' 'not-done' '[mark as undone]:index:_index -u' 'global' '[use global database]' 'TODO' '[generate TODO file]' 'all' '[show all items]' 'filter' '[show items matching filter]:filter' ) for arg in ${(k)arg_pair}; { arg_generic+='(--'$arg')-'${arg_pair[$arg]}${arg_desc[$arg]} arg_generic+='(-'${arg_pair[$arg]}')--'${arg}${arg_desc[$arg]} } function _index () { typeset i typeset -a index desc tdoptions for i in $*; do case $i in -u) tdoptions=(--filter done) esac done for i in $(todo $tdoptions --format display='%n '); do index+=${i}:$(todo $tdoptions --format display='%t' $i) done _describe -t items index index } function _color () { if compset -P '*='; then _wanted color expl 'color' \ compadd black red green yellow blue magenta cyan white default else _wanted item expl 'item' \ compadd -S '=' veryhigh high medium low verylow title info fi } function _format () { } function _priority () { } case $service in tda) _arguments -s $arg_add ;; tde|tdd) _arguments -s ':index:_index' ;; tdr) zstyle ':completion:*:tdr:*' ignore-line yes _arguments -s '*:index:_index' ;; *todo) _arguments -s $arg_generic ;; esac