diff options
Diffstat (limited to 'etc/completions')
-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 |