mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-11 00:10:08 +00:00
Updated to latest version of taskwarrior completions (using Taskwarrior 2.0b4)
This commit is contained in:
parent
f4944d5a95
commit
5f95d018e8
1 changed files with 64 additions and 96 deletions
|
@ -1,37 +1,37 @@
|
||||||
#compdef task
|
#compdef task
|
||||||
#
|
|
||||||
# zsh completion for taskwarrior
|
# zsh completion for taskwarrior
|
||||||
#
|
#
|
||||||
|
# taskwarrior - a command line task list manager.
|
||||||
|
#
|
||||||
# Copyright 2010 - 2011 Johannes Schlatow
|
# Copyright 2010 - 2011 Johannes Schlatow
|
||||||
# Copyright 2009 P.C. Shyamshankar
|
# Copyright 2009 P.C. Shyamshankar
|
||||||
# All rights reserved.
|
|
||||||
#
|
#
|
||||||
# This script is part of the taskwarrior project.
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify it under
|
# The above copyright notice and this permission notice shall be included
|
||||||
# the terms of the GNU General Public License as published by the Free Software
|
# in all copies or substantial portions of the Software.
|
||||||
# Foundation; either version 2 of the License, or (at your option) any later
|
|
||||||
# version.
|
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
# details.
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License along with
|
# http://www.opensource.org/licenses/mit-license.php
|
||||||
# this program; if not, write to the
|
|
||||||
#
|
|
||||||
# Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor,
|
|
||||||
# Boston, MA
|
|
||||||
# 02110-1301
|
|
||||||
# USA
|
|
||||||
#
|
#
|
||||||
typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers
|
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_config=($(task _config))
|
_task_config=($(task _config))
|
||||||
|
_task_columns=($(task _columns))
|
||||||
_task_modifiers=(
|
_task_modifiers=(
|
||||||
'before' \
|
'before' \
|
||||||
'after' \
|
'after' \
|
||||||
|
@ -46,39 +46,19 @@ _task_modifiers=(
|
||||||
'word' \
|
'word' \
|
||||||
'noword'
|
'noword'
|
||||||
)
|
)
|
||||||
|
_task_conjunctions=(
|
||||||
|
'and' \
|
||||||
|
'or' \
|
||||||
|
'xor' \
|
||||||
|
'\)'
|
||||||
|
'\('
|
||||||
|
)
|
||||||
_task_cmds=($(task _commands))
|
_task_cmds=($(task _commands))
|
||||||
_task_zshcmds=( ${(f)"$(task _zshcommands)"} )
|
_task_zshcmds=( ${(f)"$(task _zshcommands)"} )
|
||||||
|
|
||||||
|
|
||||||
_task_idCmds=(
|
|
||||||
'append' \
|
|
||||||
'prepend' \
|
|
||||||
'annotate' \
|
|
||||||
'denotate' \
|
|
||||||
'edit' \
|
|
||||||
'duplicate' \
|
|
||||||
'info' \
|
|
||||||
'start' \
|
|
||||||
'stop' \
|
|
||||||
'done'
|
|
||||||
)
|
|
||||||
|
|
||||||
_task_idCmdsDesc=(
|
|
||||||
'append:Appends more description to an existing task.' \
|
|
||||||
'prepend:Prepends more description to an existing task.' \
|
|
||||||
'annotate:Adds an annotation to an existing task.' \
|
|
||||||
'denotate:Deletes an annotation of an existing task.' \
|
|
||||||
'edit:Launches an editor to let you modify a task directly.' \
|
|
||||||
'duplicate:Duplicates the specified task, and allows modifications.' \
|
|
||||||
'info:Shows all data, metadata for specified task.' \
|
|
||||||
'start:Marks specified task as started.' \
|
|
||||||
'stop:Removes the start time from a task.' \
|
|
||||||
'done:Marks the specified task as completed.'
|
|
||||||
)
|
|
||||||
|
|
||||||
_task() {
|
_task() {
|
||||||
_arguments -s -S \
|
_arguments -s -S \
|
||||||
"*::task command:_task_commands"
|
"*::task default:_task_default"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +128,7 @@ _regex_words values 'task frequencies' \
|
||||||
'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' \
|
||||||
'quarterly:Every three months' \
|
'quarterly:Every three months' \
|
||||||
'semiannual:Every six months' \
|
'semiannual:Every six months' \
|
||||||
'annual:Every year' \
|
'annual:Every year' \
|
||||||
|
@ -196,22 +177,13 @@ _regex_arguments _task_attributes "${args[@]}"
|
||||||
|
|
||||||
## task commands
|
## task commands
|
||||||
|
|
||||||
# default completion
|
# filter completion
|
||||||
(( $+functions[_task_default] )) ||
|
(( $+functions[_task_filter] )) ||
|
||||||
_task_default() {
|
_task_filter() {
|
||||||
_task_attributes "$@"
|
_task_attributes "$@"
|
||||||
}
|
|
||||||
|
|
||||||
# commands expecting an ID
|
# TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command
|
||||||
(( $+functions[_task_id] )) ||
|
_describe -t default 'task conjunctions' _task_conjunctions
|
||||||
_task_id() {
|
|
||||||
if (( CURRENT < 3 )); then
|
|
||||||
# update IDs
|
|
||||||
_task_zshids=( ${(f)"$(task _zshids)"} )
|
|
||||||
_describe -t values 'task IDs' _task_zshids
|
|
||||||
else
|
|
||||||
_task_attributes "$@"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# merge completion
|
# merge completion
|
||||||
|
@ -235,46 +207,42 @@ _task_pull() {
|
||||||
_files
|
_files
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# execute completion
|
||||||
|
(( $+functions[_task_execute] )) ||
|
||||||
|
_task_execute() {
|
||||||
|
_files
|
||||||
|
}
|
||||||
|
|
||||||
# modify (task [0-9]* ...) completion
|
# id-only completion
|
||||||
(( $+functions[_task_modify] )) ||
|
(( $+functions[_task_id] )) ||
|
||||||
_task_modify() {
|
_task_id() {
|
||||||
_describe -t commands 'task command' _task_idCmdsDesc
|
_describe -t values 'task IDs' _task_zshids
|
||||||
_task_attributes "$@"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## first level completion => task sub-command completion
|
## first level completion => task sub-command completion
|
||||||
(( $+functions[_task_commands] )) ||
|
(( $+functions[_task_default] )) ||
|
||||||
_task_commands() {
|
_task_default() {
|
||||||
local cmd ret=1
|
local cmd ret=1
|
||||||
if (( CURRENT == 1 )); then
|
|
||||||
# update IDs
|
|
||||||
_task_zshids=( ${(f)"$(task _zshids)"} )
|
|
||||||
|
|
||||||
_describe -t commands 'task command' _task_zshcmds
|
integer i=1
|
||||||
_describe -t values 'task IDs' _task_zshids
|
while (( i < $#words ))
|
||||||
# TODO match more than one ID
|
do
|
||||||
elif [[ $words[1] =~ ^[0-9]*$ ]] then
|
cmd="${_task_cmds[(r)$words[$i]]}"
|
||||||
_call_function ret _task_modify
|
if (( $#cmd )); then
|
||||||
return ret
|
_call_function ret _task_${cmd} ||
|
||||||
else
|
_call_function ret _task_filter ||
|
||||||
# local curcontext="${curcontext}"
|
_message "No command remaining."
|
||||||
# cmd="${_task_cmds[(r)$words[1]:*]%%:*}"
|
return ret
|
||||||
cmd="${_task_cmds[(r)$words[1]]}"
|
fi
|
||||||
idCmd="${(M)_task_idCmds[@]:#$words[1]}"
|
(( i++ ))
|
||||||
if (( $#cmd )); then
|
done
|
||||||
# curcontext="${curcontext%:*:*}:task-${cmd}"
|
|
||||||
|
|
||||||
if (( $#idCmd )); then
|
# update IDs
|
||||||
_call_function ret _task_id
|
_task_zshids=( ${(f)"$(task _zshids)"} )
|
||||||
else
|
|
||||||
_call_function ret _task_${cmd} ||
|
_describe -t commands 'task command' _task_zshcmds
|
||||||
_call_function ret _task_default ||
|
_describe -t values 'task IDs' _task_zshids
|
||||||
_message "No command remaining."
|
_call_function ret _task_filter
|
||||||
fi
|
|
||||||
else
|
return ret
|
||||||
_message "Unknown subcommand ${cmd}"
|
|
||||||
fi
|
|
||||||
return ret
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue