lincheney / fzf-tab-completion

Tab completion using fzf
GNU General Public License v3.0
623 stars 40 forks source link

terraform auto-complete not working #98

Closed widogg closed 4 months ago

widogg commented 5 months ago

Hi! I've started using fzf-tab very recently, I've switched from fzf-obc.

I've noticed that autocomplete doesn't seem to work with terraform commands, when I type terraform <TAB>, it shows a list of files in the current directory, instead of TF arguments (like plan or apply).

In my particular scenario, I have installed terraform from repo (Ubuntu 22), but I also have binaries for each version in ~/bin/ named such as terraform-1.1, terraform-1.3, etc. I know there are other ways to make it work, but I like this one. I don't intend for auto-complete to work with all these scenarios, but I do expect it to work with the one installed globally.

lincheney commented 4 months ago

Hi What is your output of running complete -p terraform ? You may need to attempt tab completion first before running that command. For example, I get: complete -C 'terraform' terraform

If you get something like bash: complete: terraform: no completion specification but fzf-obc works for you, can you also run complete -p terraform when using fzf-obc and get that output.

widogg commented 4 months ago

Hi. I'm gonna close this incident because, while I was pretty sure this was working with fzf-obc, it actually doesn´t. Sorry I added that part of (mis)information.

Also, I did tried the commands you asked:

$ complete -p terraform
bash: complete: terraform: no completion specification

but if I put the command you mention complete -C 'terraform' terraform, now autocomplete works as expected

I'm guessing I have to add that line into my bashrc?

lincheney commented 4 months ago

For terraform, what you're meant to do is this: https://developer.hashicorp.com/terraform/cli/commands#shell-tab-completion But I think this literally just does what you said, adds something like complete -C 'terraform' terraform to your .bashrc.

For your other versions of terraform e.g. ~/bin/terraform-1.1, I believe if you try something like complete -C ~/bin/terraform-1.1 terraform-1.1 that may work.

widogg commented 4 months ago

That did the trick. Heh, long time using terraform and never saw this.

Thanks for the help