Skip to content

Commit 2265dda

Browse files
authored
Merge pull request #249 from bfarayev/feature/bash-autocomplete
Bash autocompletion for task
2 parents 0494d7e + fbd1361 commit 2265dda

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

completion/bash/task.bash

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
_task_completion()
2+
{
3+
local scripts;
4+
local curr_arg;
5+
6+
# Remove colon from word breaks
7+
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
8+
9+
scripts=$(task -l | sed '1d' | sed 's/^\* //' | awk '{ print $1 }');
10+
11+
curr_arg="${COMP_WORDS[COMP_CWORD]:-"."}"
12+
13+
# Do not accept more than 1 argument
14+
if [ "${#COMP_WORDS[@]}" != "2" ]; then
15+
return
16+
fi
17+
18+
COMPREPLY=($(compgen -c | echo "$scripts" | grep $curr_arg));
19+
}
20+
21+
complete -F _task_completion task

0 commit comments

Comments
 (0)