mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 19:03:07 +02:00
Scripts
- modified zsh tab completion to support 2.0 syntax
This commit is contained in:
parent
25e3453321
commit
3e73f43272
1 changed files with 30 additions and 72 deletions
|
@ -32,6 +32,7 @@ _task_projects=($(task _projects))
|
|||
_task_tags=($(task _tags))
|
||||
_task_ids=($(task _ids))
|
||||
_task_config=($(task _config))
|
||||
_task_columns=($(task _columns))
|
||||
_task_modifiers=(
|
||||
'before' \
|
||||
'after' \
|
||||
|
@ -49,33 +50,6 @@ _task_modifiers=(
|
|||
_task_cmds=($(task _commands))
|
||||
_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() {
|
||||
_arguments -s -S \
|
||||
"*::task command:_task_commands"
|
||||
|
@ -203,18 +177,6 @@ _task_default() {
|
|||
_task_attributes "$@"
|
||||
}
|
||||
|
||||
# commands expecting an ID
|
||||
(( $+functions[_task_id] )) ||
|
||||
_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
|
||||
(( $+functions[_task_merge] )) ||
|
||||
_task_merge() {
|
||||
|
@ -236,46 +198,42 @@ _task_pull() {
|
|||
_files
|
||||
}
|
||||
|
||||
# execute completion
|
||||
(( $+functions[_task_execute] )) ||
|
||||
_task_execute() {
|
||||
_files
|
||||
}
|
||||
|
||||
# modify (task [0-9]* ...) completion
|
||||
(( $+functions[_task_modify] )) ||
|
||||
_task_modify() {
|
||||
_describe -t commands 'task command' _task_idCmdsDesc
|
||||
_task_attributes "$@"
|
||||
# id-only completion
|
||||
(( $+functions[_task_id] )) ||
|
||||
_task_id() {
|
||||
_describe -t values 'task IDs' _task_zshids
|
||||
}
|
||||
|
||||
## first level completion => task sub-command completion
|
||||
(( $+functions[_task_commands] )) ||
|
||||
_task_commands() {
|
||||
local cmd ret=1
|
||||
if (( CURRENT == 1 )); then
|
||||
# update IDs
|
||||
_task_zshids=( ${(f)"$(task _zshids)"} )
|
||||
|
||||
_describe -t commands 'task command' _task_zshcmds
|
||||
_describe -t values 'task IDs' _task_zshids
|
||||
# TODO match more than one ID
|
||||
elif [[ $words[1] =~ ^[0-9]*$ ]] then
|
||||
_call_function ret _task_modify
|
||||
return ret
|
||||
else
|
||||
# local curcontext="${curcontext}"
|
||||
# cmd="${_task_cmds[(r)$words[1]:*]%%:*}"
|
||||
cmd="${_task_cmds[(r)$words[1]]}"
|
||||
idCmd="${(M)_task_idCmds[@]:#$words[1]}"
|
||||
if (( $#cmd )); then
|
||||
# curcontext="${curcontext%:*:*}:task-${cmd}"
|
||||
integer i=1
|
||||
while (( i < $#words ))
|
||||
do
|
||||
cmd="${_task_cmds[(r)$words[$i]]}"
|
||||
if (( $#cmd )); then
|
||||
_call_function ret _task_${cmd} ||
|
||||
_call_function ret _task_default ||
|
||||
_message "No command remaining."
|
||||
return ret
|
||||
fi
|
||||
(( i++ ))
|
||||
done
|
||||
|
||||
if (( $#idCmd )); then
|
||||
_call_function ret _task_id
|
||||
else
|
||||
_call_function ret _task_${cmd} ||
|
||||
_call_function ret _task_default ||
|
||||
_message "No command remaining."
|
||||
fi
|
||||
else
|
||||
_message "Unknown subcommand ${cmd}"
|
||||
fi
|
||||
return ret
|
||||
fi
|
||||
# update IDs
|
||||
_task_zshids=( ${(f)"$(task _zshids)"} )
|
||||
|
||||
_describe -t commands 'task command' _task_zshcmds
|
||||
_describe -t values 'task IDs' _task_zshids
|
||||
_call_function ret _task_default
|
||||
|
||||
return ret
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue