@@ -16,14 +16,14 @@ Generate your own Taskfile at [taskfile.sh](https://taskfile.sh).
16
16
- Easy to understand and maintain
17
17
- Automatically generated list of available task
18
18
19
- ## How does it work?
19
+ # How does it work?
20
20
21
21
Taskfiles are simple bash scripts, but an easy-to-read function format. There are some things that we need to explain
22
22
for our Taskfile setup. It all starts with a ` Taskfile ` . Download your ` Taskfile ` from
23
23
[ taskfile.sh] ( https://taskfile.sh ) and save it. Make sure the Taskfile is executable: ` chmod +x ./Taskfile ` . You can now
24
24
run ` ./Taskfile ` in your terminal.
25
25
26
- ### Tasks
26
+ ## Tasks
27
27
28
28
A task is defined by creating a function that starts with ` task: ` . This defines a task that can be triggered by running
29
29
the ` ./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
40
40
In a task you can call other functions, and run all tooling you desire. Now running ` ./Taskfile example ` will execute
41
41
the new task.
42
42
43
- ### Sections
43
+ ## Sections
44
44
45
45
To group multiple tasks, sections can be created in your Taskfile. A section is created by creating a comment line with
46
46
a double hashtag like so:
@@ -51,17 +51,46 @@ a double hashtag like so:
51
51
52
52
Lines with only a single ` # ` will not appear as section in ` task:help ` and can be seen as plain comments.
53
53
54
- ### Help command
54
+ ## Help command
55
55
56
56
Running ` ./Taskfile help ` , the ` task:help ` function is triggered. This task will list all available sections and tasks
57
57
using the double ` ## ` comments you've learned about above. Now it's clear how you can run any other task!
58
58
59
- ## Credits
59
+ # Auto-completion
60
+
61
+ Autocompletion works when you use ` zsh ` with ` 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
+ ** Note:** if your task name contains ` : ` characters, the autocomplete functionality will break. Replace the ` : `
86
+ character in your task names to prevent this.
87
+
88
+ # Credits
60
89
61
90
This Taskfile setup is based on [ Adrian Cooney's Taskfile] ( https://github.com/adriancooney/Taskfile ) and is widely
62
91
adopted by [ Enrise] ( https://enrise.com ) in our modified flavour.
63
92
64
- ## Contributors
93
+ # Contributors
65
94
66
95
A big thanks to all the contributors of Taskfile!
67
96
0 commit comments