Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bash, ZSH and Windows command line completion #103

Closed
harobed opened this issue Mar 11, 2018 · 17 comments
Closed

Add Bash, ZSH and Windows command line completion #103

harobed opened this issue Mar 11, 2018 · 17 comments
Labels
help wanted Issues that could benefit from members of the community contributing their expertise or experience. type: feature A new feature or functionality.
Milestone

Comments

@harobed
Copy link

harobed commented Mar 11, 2018

Add bash and zsh autocomplete feature.

@harobed harobed changed the title Add bash and zsh autocomplete feature Add bash and zsh auto complete / completion feature Mar 12, 2018
@andreynering andreynering added the type: feature A new feature or functionality. label Mar 13, 2018
@andreynering andreynering added this to the v2.x milestone Mar 13, 2018
@andreynering andreynering added the help wanted Issues that could benefit from members of the community contributing their expertise or experience. label Mar 13, 2018
@andreynering
Copy link
Member

@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.

@sawadashota
Copy link

Simply, I use zsh completion.
https://github.com/sawadashota/go-task-completions

This was referenced Apr 27, 2018
@andreynering andreynering changed the title Add bash and zsh auto complete / completion feature Add Bash, ZSH and Windows command line completion Sep 8, 2018
@andreynering
Copy link
Member

Edited title to include Windows as asked on #127

@rmmcnulty9
Copy link

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:

  • included files
  • uppercase tasks, I went with lowercase otherwise it would return some of the variables I have defined

This also seems like a nice resource: https://iridakos.com/tutorials/2018/03/01/bash-programmable-completion-tutorial.html

@smyrman
Copy link
Contributor

smyrman commented Apr 9, 2019

I thing I have linked this previously, but another resource is:

@bfarayev
Copy link

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.

@andreynering
Copy link
Member

@bfarayev Pull requests are more than welcome!

@Chi-teck
Copy link

Chi-teck commented Feb 4, 2020

Can this be implemented as new Task command?
Example:
task generate-completion --bash >> ~/.bashrc

@andreynering
Copy link
Member

Can this be implemented as new Task command?
Example:
task generate-completion --bash >> ~/.bashrc

Does other tools usually do that?

@Chi-teck
Copy link

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.

@andreynering
Copy link
Member

@Chi-teck Sounds like a good idea. Can you create a separate issue for that?

@Chi-teck
Copy link

@andreynering what is the scope of this ticket then?

@andreynering
Copy link
Member

@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.

@ghostsquad
Copy link
Contributor

ghostsquad commented Mar 16, 2020

@sawadashota I opened a PR to improve the installation of autocompletions here:

sawadashota/go-task-completions#2

One thing I noticed is that task -l only prints targets with descriptions. I think it should print all targets, regardless of description.

@weeping-somnambulist
Copy link

Looks like the completions are completed and all that needs done is to update the docs, correct?

@andreynering
Copy link
Member

Yep, closing this as completed.

If anyone think anything is missing, please open another issue.

@seebi
Copy link

seebi commented Jan 20, 2022

I just commented in #293 on the missing things ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that could benefit from members of the community contributing their expertise or experience. type: feature A new feature or functionality.
Projects
None yet
Development

No branches or pull requests

10 participants