Skip to content
New issue

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

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

Already on GitHub? # to your account

[Enhancement]: enable bash completion #113

Open
boukendesho opened this issue Jul 7, 2024 · 3 comments
Open

[Enhancement]: enable bash completion #113

boukendesho opened this issue Jul 7, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@boukendesho
Copy link

boukendesho commented Jul 7, 2024

What changes would you like?

Is it possible to enable bash completion ?

Any extra information?

I've tried terraform -install-autocomplete but don't work.

And i found this bash completion script from gist

@boukendesho boukendesho added the enhancement New feature or request label Jul 7, 2024
@boukendesho
Copy link
Author

Sorry , terraform -install-autocomplete works. I forget restart my shell.

But is it possbile that enable bash completion by default with snap?

@lengau
Copy link

lengau commented Jul 16, 2024

+1 on this.

Doing quick examination, terraform -install-autocomplete simply adds the following line to your bashrc:

complete -C /snap/terraform/711/terraform terraform

(Or I guess equivalent for the particular revision.)

A completion file that simply contains complete -C /snap/bin/terraform terraform and a completer key in the app entry should be sufficient.

@jnsgruk
Copy link
Member

jnsgruk commented Jul 17, 2024

Hmm, gave that a go locally, but no dice.

diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index c86522d..398fb3a 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -30,6 +30,7 @@ icon: snap/gui/terraform.png
 apps:
   terraform:
     command: terraform
+    completer: terraform-completer
 
 platforms:
   amd64:
@@ -56,5 +57,9 @@ parts:
       go mod download
       go build -ldflags "${LDFLAGS}"
       cp terraform $SNAPCRAFT_PART_INSTALL/terraform
+
+      echo -e '#!/usr/bin/env bash\ncomplete -C terraform terraform' > $CRAFT_PART_INSTALL/terraform-completer
+      chmod +x $CRAFT_PART_INSTALL/terraform-completer
     stage:
       - terraform
+      - terraform-completer

Will try a bit later if I get time, but feel free to have a play!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants