diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2009-01-17 08:10:24 +0100 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2009-01-17 08:10:24 +0100 |
commit | 0b1d43115923601a67933514e3fb628bbb6520f2 (patch) | |
tree | 8a9f5f0291655733b17f2a9ca6e66580f7927cda | |
parent | 08bb19a352baa5ee2fea7bf23aedf36066636783 (diff) |
_devtodo: Added proper completion for --sort
-rw-r--r-- | etc/completions/_devtodo | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/etc/completions/_devtodo b/etc/completions/_devtodo index 0368a24..05d1172 100644 --- a/etc/completions/_devtodo +++ b/etc/completions/_devtodo @@ -35,7 +35,7 @@ arg_generic=( '--date-format[strftime time formet]:time string: ' '*--format[define format]:format:_format' '*--use-format[output format]:format:_format' - '--sort[sort database]:expression: ' + '--sort[sort database]:sort expression:_sort' '--paranoid[paranoid parmissions etc]' '--database-loaders[loader order]:database loader: ' '--backup[backup database]:count: ' @@ -132,6 +132,25 @@ function _priority () { compadd default $priorities } +function _sort () { + typeset -a keys used_prefixes + typeset key prefix='' + keys=(created completed text priority duration none done) + for key in $keys; { + [[ $key != none ]] && keys+="-$key" + } + + if [[ -prefix *, ]] { + prefix=${words[$CURRENT]%,*}, + used_prefixes=(${(s:,:)prefix}) + for key in $used_prefixes; { + [[ $key == -* ]] && used_prefixes+=$key[2,-1] || used_prefixes+=-$key + } + } + _wanted expression expl 'sort expression' \ + compadd -F used_prefixes -qS , -P "$prefix" $keys +} + case $service in tda) _arguments -s $arg_add |