From 393712ead2cadfa6516fb8f2bdb03371464003a4 Mon Sep 17 00:00:00 2001 From: Bakhtiyar Farayev Date: Fri, 30 Aug 2019 09:59:03 +1000 Subject: [PATCH 1/2] Add initial version of bash autocomplete --- completion/task.bash | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 completion/task.bash diff --git a/completion/task.bash b/completion/task.bash new file mode 100644 index 00000000..88820076 --- /dev/null +++ b/completion/task.bash @@ -0,0 +1,21 @@ +_task_completion() +{ + local scripts; + local curr_arg; + + # Remove colon from work breaks + COMP_WORDBREAKS=${COMP_WORDBREAKS//:} + + scripts=$(task -l | sed '1d' | sed 's/^\* //' | awk '{ print $1 }'); + + curr_arg="${COMP_WORDS[COMP_CWORD]:-"."}" + + # Do not accept more than 1 argument + if [ "${#COMP_WORDS[@]}" != "2" ]; then + return + fi + + COMPREPLY=($(compgen -c | echo "$scripts" | grep $curr_arg)); +} + +complete -F _task_completion task From fbd13614a5109cf6bd595255a099baf1b5edd634 Mon Sep 17 00:00:00 2001 From: Bakhtiyar Farayev Date: Tue, 5 Nov 2019 10:30:01 +1100 Subject: [PATCH 2/2] Fix typo and re-organize the folder structure for task completion --- completion/{ => bash}/task.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename completion/{ => bash}/task.bash (92%) diff --git a/completion/task.bash b/completion/bash/task.bash similarity index 92% rename from completion/task.bash rename to completion/bash/task.bash index 88820076..1e212979 100644 --- a/completion/task.bash +++ b/completion/bash/task.bash @@ -3,7 +3,7 @@ _task_completion() local scripts; local curr_arg; - # Remove colon from work breaks + # Remove colon from word breaks COMP_WORDBREAKS=${COMP_WORDBREAKS//:} scripts=$(task -l | sed '1d' | sed 's/^\* //' | awk '{ print $1 }');