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:
John Florian 2009-07-30 23:19:10 -04:00
parent 0bad0277fe
commit ede746ba16
2 changed files with 53 additions and 24 deletions

View file

@ -4,6 +4,8 @@
1.8.1 1.8.1
+ Fixed bug #231 that broke the build on OpenBSD 32-bit due to a time_t + Fixed bug #231 that broke the build on OpenBSD 32-bit due to a time_t
and int collision (thanks to Pietro Cerutti). and int collision (thanks to Pietro Cerutti).
+ Fixed bug #241 that prevented bash's tab-completion of projects in Fedora
11 and likely anything using bash-4 (John Florian)
------ old releases ------------------------------ ------ old releases ------------------------------

View file

@ -48,10 +48,6 @@
# http://taskwarrior.org # http://taskwarrior.org
# #
_task_get_projects() {
task _projects
}
_task_get_tags() { _task_get_tags() {
task _tags task _tags
} }
@ -60,6 +56,10 @@ _task_get_config() {
task _config task _config
} }
_task_offer_projects() {
COMPREPLY=( $(compgen -W "$(task _projects)" -- ${cur/*:/}) )
}
_task() _task()
{ {
local cur prev opts base local cur prev opts base
@ -67,16 +67,41 @@ _task()
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" 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)" opts="$(task _commands) $(task _ids)"
case "${prev}" in
:)
case "${prev2}" in
pro*)
_task_offer_projects
return 0
;;
esac
;;
*)
case "${cur}" in case "${cur}" in
pro*:*) pro*:*)
local projects=$(_task_get_projects) _task_offer_projects
local partial_project="${cur/*:/}"
COMPREPLY=( $(compgen -W "${projects}" -- ${partial_project}) )
return 0 return 0
;; ;;
:)
case "${prev}" in
pro*)
_task_offer_projects
return 0
;;
esac
;;
+*) +*)
local tags=$(_task_get_tags | sed 's/^/+/') local tags=$(_task_get_tags | sed 's/^/+/')
COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) )
@ -93,6 +118,8 @@ _task()
return 0 return 0
;; ;;
esac esac
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0 return 0