@@ -16,14 +16,14 @@ Generate your own Taskfile at [taskfile.sh](https://taskfile.sh).
1616- Easy to understand and maintain
1717- Automatically generated list of available task
1818
19- ## How does it work?
19+ # How does it work?
2020
2121Taskfiles are simple bash scripts, but an easy-to-read function format. There are some things that we need to explain
2222for our Taskfile setup. It all starts with a ` Taskfile ` . Download your ` Taskfile ` from
2323[ taskfile.sh] ( https://taskfile.sh ) and save it. Make sure the Taskfile is executable: ` chmod +x ./Taskfile ` . You can now
2424run ` ./Taskfile ` in your terminal.
2525
26- ### Tasks
26+ ## Tasks
2727
2828A task is defined by creating a function that starts with ` task: ` . This defines a task that can be triggered by running
2929the ` ./Taskfile ` . Right next to the task, you should add a task definition with two hashes. This will let the
@@ -40,7 +40,7 @@ function task:example { ## Show some example text
4040In a task you can call other functions, and run all tooling you desire. Now running ` ./Taskfile example ` will execute
4141the new task.
4242
43- ### Sections
43+ ## Sections
4444
4545To group multiple tasks, sections can be created in your Taskfile. A section is created by creating a comment line with
4646a double hashtag like so:
@@ -51,17 +51,43 @@ a double hashtag like so:
5151
5252Lines with only a single ` # ` will not appear as section in ` task:help ` and can be seen as plain comments.
5353
54- ### Help command
54+ ## Help command
5555
5656Running ` ./Taskfile help ` , the ` task:help ` function is triggered. This task will list all available sections and tasks
5757using the double ` ## ` comments you've learned about above. Now it's clear how you can run any other task!
5858
59- ## Credits
59+ # Auto-completion
60+
61+ Autocompletion works when you use ` zsh ` and ` oh-my-zsh ` . Create the following file in your oh-my-zsh directory
62+ ` ~/.oh-my-zsh/completions/_task.zsh ` :
63+
64+ ``` shell
65+ # compdef task
66+
67+ _task () {
68+ local -a commands
69+ local tasks=$( task comp_targets)
70+
71+ while IFS= read -r line; do
72+ if [[ -n " $line " ]]; then
73+ commands+=(" $line " )
74+ fi
75+ done <<< " $tasks"
76+
77+ _describe -t commands ' task commands' commands
78+ }
79+
80+ _task " $@ "
81+ ```
82+
83+ Now after running ` task shorthand ` , your ` task ` commands will get autocompleted.
84+
85+ # Credits
6086
6187This Taskfile setup is based on [ Adrian Cooney's Taskfile] ( https://github.com/adriancooney/Taskfile ) and is widely
6288adopted by [ Enrise] ( https://enrise.com ) in our modified flavour.
6389
64- ## Contributors
90+ # Contributors
6591
6692A big thanks to all the contributors of Taskfile!
6793
0 commit comments