Zsh completion

* fixed ID completion after edit/info/annotate/start/...
* now IDs will be updated any time the completion function is called
This commit is contained in:
Johannes Schlatow 2011-01-09 18:01:53 +01:00
parent 914626e2b2
commit 976cd284ff

View file

@ -31,7 +31,6 @@ typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers
_task_projects=($(task _projects))
_task_tags=($(task _tags))
_task_ids=($(task _ids))
_task_zshids=( ${(f)"$(task _zshids)"} )
_task_config=($(task _config))
_task_modifiers=(
'before' \
@ -50,20 +49,18 @@ _task_modifiers=(
_task_cmds=($(task _commands))
_task_zshcmds=( ${(f)"$(task _zshcommands)"} )
# concat zshcmds and zshids
_task_cmds_ids=($_task_zshcmds $_task_zshids)
_task_idCmds=(
'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.'
'append' \
'prepend' \
'annotate' \
'denotate' \
'edit' \
'duplicate' \
'info' \
'start' \
'stop' \
'done'
)
_task_idCmdsDesc=(
@ -209,6 +206,8 @@ _task_default() {
(( $+functions[_task_id] )) ||
_task_id() {
if (( CURRENT < 3 )); then
# update IDs
_task_zshids=( ${(f)"$(task _zshids)"} )
_describe -t ids 'task IDs' _task_zshids
else
_task_attributes "$@"
@ -233,11 +232,12 @@ _task_modify() {
_task_commands() {
local cmd ret=1
if (( CURRENT == 1 )); then
#TODO fix descriptions
# update IDs
_task_zshids=( ${(f)"$(task _zshids)"} )
_describe -t commands 'task command' _task_cmds_ids
_describe -t commands 'task command' _task_zshcmds
_describe -t ids 'task IDs' _task_zshids
# TODO match more than one ID
# TODO sorting (ids below commands)
elif [[ $words[1] =~ ^[0-9]*$ ]] then
_call_function ret _task_modify
return ret