Scripts
- modified zsh tab completion to support 2.0 syntax
This commit is contained in:
@@ -32,6 +32,7 @@ _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' \
|
||||||
@@ -49,33 +50,6 @@ _task_modifiers=(
|
|||||||
_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 command:_task_commands"
|
||||||
@@ -203,18 +177,6 @@ _task_default() {
|
|||||||
_task_attributes "$@"
|
_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
|
# merge completion
|
||||||
(( $+functions[_task_merge] )) ||
|
(( $+functions[_task_merge] )) ||
|
||||||
_task_merge() {
|
_task_merge() {
|
||||||
@@ -236,46 +198,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_commands] )) ||
|
||||||
_task_commands() {
|
_task_commands() {
|
||||||
local cmd ret=1
|
local cmd ret=1
|
||||||
if (( CURRENT == 1 )); then
|
|
||||||
|
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
|
||||||
|
|
||||||
# update IDs
|
# update IDs
|
||||||
_task_zshids=( ${(f)"$(task _zshids)"} )
|
_task_zshids=( ${(f)"$(task _zshids)"} )
|
||||||
|
|
||||||
_describe -t commands 'task command' _task_zshcmds
|
_describe -t commands 'task command' _task_zshcmds
|
||||||
_describe -t values 'task IDs' _task_zshids
|
_describe -t values 'task IDs' _task_zshids
|
||||||
# TODO match more than one ID
|
_call_function ret _task_default
|
||||||
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}"
|
|
||||||
|
|
||||||
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
|
return ret
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user