Add bash and zsh autocomplete feature.
@harobed I'd love to receive contributions in this one, since I don't actually know how that works. Let me know if you want to work in it.
Simply, I use zsh completion.
https://github.com/sawadashota/go-task-completions
Edited title to include Windows as asked on #127
I am very interested in this feature. I have a very simple and not very complete command I use for bash:
# Taskfile.yml autocomplete - ASSUMES ALL TASKS ARE LOWERCASE
complete -W "\`test -e Taskfile.yml && grep -oE '^\s\s[a-z0-9_-]+:([^=]|$)' Taskfile.yml | sed 's/[^a-zA-Z0-9_-]*$//'\`" task
This does not work with:
This also seems like a nice resource: https://iridakos.com/tutorials/2018/03/01/bash-programmable-completion-tutorial.html
I thing I have linked this previously, but another resource is:
I've made some work on bash autocompletion here: https://github.com/bfarayev/task/blob/feature/autocomplete/completion/task.bash
I've tested it on my fork of task, so need to check if it'd work with the latest release. Happy to submit a PR after testing.
@bfarayev Pull requests are more than welcome!
Can this be implemented as new Task command?
Example:
task generate-completion --bash >> ~/.bashrc
Can this be implemented as new Task command?
Example:
task generate-completion --bash >> ~/.bashrc
Does other tools usually do that?
Drush 8 used to have init command that installed completion file.
https://github.com/drush-ops/drush/blob/8.3.2/commands/core/init.drush.inc#L83
Also https://github.com/bamarni/symfony-console-autocomplete is widely used tool for generating completions for Symfony Console commands.
Typically such approach is used in applications that distributed as a single file executable. If an application has installation/uninstallation procedure it's probably better to install/uninstall the completions automatically.
@Chi-teck Sounds like a good idea. Can you create a separate issue for that?
@andreynering what is the scope of this ticket then?
@Chi-teck This issue is about creating the completion scripts alone.
I propose one to implement the auto-install command you mentioned. As a comment, it'd be more likely forgotten with time.
@sawadashota I opened a PR to improve the installation of autocompletions here:
https://github.com/sawadashota/go-task-completions/pull/2
One thing I noticed is that task -l only prints targets with descriptions. I think it should print all targets, regardless of description.
Most helpful comment
I've made some work on bash autocompletion here: https://github.com/bfarayev/task/blob/feature/autocomplete/completion/task.bash
I've tested it on my fork of task, so need to check if it'd work with the latest release. Happy to submit a PR after testing.