mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Fixed bug #241
Completion behavior has changed from bash-3 to bash-4. Even the colon character appears in COMP_WORDBREAKS of both versions, only bash-4 seems to honor it. This appears to be a bug in bash-3. Changes made here work around the problem so that completion of project names works for either version of bash.
This commit is contained in:
parent
0bad0277fe
commit
ede746ba16
2 changed files with 53 additions and 24 deletions
|
@ -48,10 +48,6 @@
|
|||
# http://taskwarrior.org
|
||||
#
|
||||
|
||||
_task_get_projects() {
|
||||
task _projects
|
||||
}
|
||||
|
||||
_task_get_tags() {
|
||||
task _tags
|
||||
}
|
||||
|
@ -60,6 +56,10 @@ _task_get_config() {
|
|||
task _config
|
||||
}
|
||||
|
||||
_task_offer_projects() {
|
||||
COMPREPLY=( $(compgen -W "$(task _projects)" -- ${cur/*:/}) )
|
||||
}
|
||||
|
||||
_task()
|
||||
{
|
||||
local cur prev opts base
|
||||
|
@ -67,30 +67,57 @@ _task()
|
|||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
if [ ${#COMP_WORDS[*]} -gt 2 ]
|
||||
then
|
||||
prev2="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
else
|
||||
prev2=""
|
||||
fi
|
||||
# echo -e "\ncur='$cur'"
|
||||
# echo "prev='$prev'"
|
||||
# echo "prev2='$prev2'"
|
||||
|
||||
opts="$(task _commands) $(task _ids)"
|
||||
|
||||
case "${cur}" in
|
||||
pro*:*)
|
||||
local projects=$(_task_get_projects)
|
||||
local partial_project="${cur/*:/}"
|
||||
COMPREPLY=( $(compgen -W "${projects}" -- ${partial_project}) )
|
||||
return 0
|
||||
case "${prev}" in
|
||||
:)
|
||||
case "${prev2}" in
|
||||
pro*)
|
||||
_task_offer_projects
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
+*)
|
||||
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
|
||||
;;
|
||||
rc.*)
|
||||
local config=$(_task_get_config | sed 's/^/rc\./')
|
||||
COMPREPLY=( $(compgen -W "${config}" -- ${cur}) )
|
||||
return 0
|
||||
*)
|
||||
case "${cur}" in
|
||||
pro*:*)
|
||||
_task_offer_projects
|
||||
return 0
|
||||
;;
|
||||
:)
|
||||
case "${prev}" in
|
||||
pro*)
|
||||
_task_offer_projects
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
+*)
|
||||
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
|
||||
;;
|
||||
rc.*)
|
||||
local config=$(_task_get_config | sed 's/^/rc\./')
|
||||
COMPREPLY=( $(compgen -W "${config}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue