mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
Oh-My-Zsh plugin to support Taskfile.yml completion
This commit is contained in:
parent
4c82a2eedf
commit
c08e9eb232
3 changed files with 49 additions and 0 deletions
20
plugins/taskfile/README.md
Normal file
20
plugins/taskfile/README.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
# `Taskfile` plugin
|
||||
|
||||
This plugin provides completion for [Task](https://taskfile.dev/), as well as the shortcut alias `t`
|
||||
|
||||
To use it add `taskfile` to the plugins array in your zshrc file.
|
||||
|
||||
```bash
|
||||
plugins=(... taskfile)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Of course, you need [Task](https://taskfile.dev/installation/) to be installed.
|
||||
|
||||
Typing `t [TAB]` will give you a list of commands provided by your `Taskfile.yml`
|
||||
|
||||
<br/>
|
||||
---
|
||||
|
||||
Thanks to [Berger91](https://github.com/Berger91/taskfile-zsh-autocompletion) for the original completion method.
|
28
plugins/taskfile/_taskfile
Normal file
28
plugins/taskfile/_taskfile
Normal file
|
@ -0,0 +1,28 @@
|
|||
#compdef task
|
||||
local state line
|
||||
declare -A opt_args
|
||||
|
||||
_task_get_tasks () {
|
||||
sed '1,/tasks:/d' Taskfile.yml | grep -iwE "^\ \ [a-z](.*)$" | sed 's/.$//' | awk '{ print $1 }'
|
||||
while read included_task
|
||||
do
|
||||
taskfile_path=$(sed "1,/$included_task:/d" Taskfile.yml | grep -m 1 -iwE "^\ \ \ taskfile: .*$" | awk '{ print $2 }')
|
||||
sed '1,/tasks:/d' $taskfile_path | grep -iwE "^\ \ [a-z](.*)$" | sed 's/.$//' | awk -v included_task="$included_task" '{ print included_task":"$1 }'
|
||||
|
||||
done < <(sed '1,/includes:/d' Taskfile.yml | grep -iwE "^\ \ [a-z](.*)$" | sed 's/.$//' | awk '{ print $1 }')
|
||||
}
|
||||
|
||||
_taskfile () {
|
||||
local state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments \
|
||||
'*: :->args'
|
||||
if [ -f Taskfile.yml ]; then
|
||||
compadd `_task_get_tasks`
|
||||
else
|
||||
echo -e "\nNo taskfile found"
|
||||
fi
|
||||
}
|
||||
|
||||
compdef _taskfile t=task
|
1
plugins/taskfile/taskfile.plugin.zsh
Normal file
1
plugins/taskfile/taskfile.plugin.zsh
Normal file
|
@ -0,0 +1 @@
|
|||
alias t=task
|
Loading…
Reference in a new issue