1
0
mirror of https://github.com/go-task/task.git synced 2025-06-02 23:27:37 +02:00

Merge pull request #249 from bfarayev/feature/bash-autocomplete

Bash autocompletion for task
This commit is contained in:
Andrey Nering 2019-11-10 19:53:33 -03:00 committed by GitHub
commit 2265dda84c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

21
completion/bash/task.bash Normal file
View File

@ -0,0 +1,21 @@
_task_completion()
{
local scripts;
local curr_arg;
# Remove colon from word 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