- Support for project names (thanks to John Florian)

- Completes tags and project names for any command,
    not just list variants (thanks to John Florian)
  - bash-completion now completes tags for removal using '-'
  - internal completion list compiled by using underscore
    variants of corresponding commands
This commit is contained in:
Federico Hernandez 2009-07-03 16:10:03 +02:00
parent 03c9cc6005
commit 8312dc1f1d

View file

@ -27,6 +27,7 @@
# The routines will do completion of:
#
# *) task subcommands
# *) project names
# *) tag names
#
# To use these routines:
@ -47,6 +48,14 @@
# http://taskwarrior.org
#
_task_get_projects() {
task _projects
}
_task_get_tags() {
task _tags
}
_task()
{
local cur prev opts base
@ -57,13 +66,22 @@ _task()
opts="active add annotate append calendar color completed delete done duplicate edit export ghistory help history import info list long ls newest next oldest overdue projects start stats stop summary tags timesheet undelete undo version"
case "${prev}" in
ls|list|long)
if [[ ${cur} == +* ]] ; then
local tags=$( task tags | egrep -v 'tags|^$'|sed 's/^/+/' )
case "${cur}" in
pro*:*)
local projects=$(_task_get_projects)
local partial_project="${cur/*:/}"
COMPREPLY=( $(compgen -W "${projects}" -- ${partial_project}) )
return 0
;;
+*)
local tags=$(_task_get_tags | sed 's/^/+/')
COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) )
return 0
;;
-*)
local tags=$(_task_get_tags | sed 's/^/-/')
COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) )
return 0
fi
;;
esac