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_projects=($(task _projects))
_task_tags=($(task _tags)) _task_tags=($(task _tags))
_task_ids=($(task _ids)) _task_ids=($(task _ids))
_task_zshids=( ${(f)"$(task _zshids)"} )
_task_config=($(task _config)) _task_config=($(task _config))
_task_modifiers=( _task_modifiers=(
'before' \ 'before' \
@ -50,20 +49,18 @@ _task_modifiers=(
_task_cmds=($(task _commands)) _task_cmds=($(task _commands))
_task_zshcmds=( ${(f)"$(task _zshcommands)"} ) _task_zshcmds=( ${(f)"$(task _zshcommands)"} )
# concat zshcmds and zshids
_task_cmds_ids=($_task_zshcmds $_task_zshids)
_task_idCmds=( _task_idCmds=(
'append:Appends more description to an existing task.' \ 'append' \
'prepend:Prepends more description to an existing task.' \ 'prepend' \
'annotate:Adds an annotation to an existing task.' \ 'annotate' \
'denotate:Deletes an annotation of an existing task.' \ 'denotate' \
'edit:Launches an editor to let you modify a task directly.' \ 'edit' \
'duplicate:Duplicates the specified task, and allows modifications.' \ 'duplicate' \
'info:Shows all data, metadata for specified task.' \ 'info' \
'start:Marks specified task as started.' \ 'start' \
'stop:Removes the start time from a task.' \ 'stop' \
'done:Marks the specified task as completed.' 'done'
) )
_task_idCmdsDesc=( _task_idCmdsDesc=(
@ -209,6 +206,8 @@ _task_default() {
(( $+functions[_task_id] )) || (( $+functions[_task_id] )) ||
_task_id() { _task_id() {
if (( CURRENT < 3 )); then if (( CURRENT < 3 )); then
# update IDs
_task_zshids=( ${(f)"$(task _zshids)"} )
_describe -t ids 'task IDs' _task_zshids _describe -t ids 'task IDs' _task_zshids
else else
_task_attributes "$@" _task_attributes "$@"
@ -233,11 +232,12 @@ _task_modify() {
_task_commands() { _task_commands() {
local cmd ret=1 local cmd ret=1
if (( CURRENT == 1 )); then 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 match more than one ID
# TODO sorting (ids below commands)
elif [[ $words[1] =~ ^[0-9]*$ ]] then elif [[ $words[1] =~ ^[0-9]*$ ]] then
_call_function ret _task_modify _call_function ret _task_modify
return ret return ret