Skip to content

[cli] Emit shell completions to stdout  #32611

@lucasew

Description

@lucasew

Terraform Version

Terraform v1.3.6
on linux_amd64

(using outdated nixpkgs stable branch)

Use Cases

  • Easier packaging
    Nix expose completions from a special folder in referenced Nix components. This feature will allow basically a no brainer easy integration with how Nix works to generate completions. Instead of the user having to do an imperative step, the completions is available only by nix-shell terraform without a global installation.

Attempted Solutions

  • terraform -install-autocomplete
    Imperative approach. Fails if you use home-manager because ~/.bashrc is a symlink to a file in the nix store, that is read only.

  • HOME=/somewhere/else terraform -install-autocomplete
    Terraform ignores the environment variable and tries to write ~/.bashrc anyway.

Proposal

The same approach rclone uses to expose completions, ex:

  • rclone completion bash generate bash completion and output to stdout
  • It also works with fish, powershell and zsh, but support these shells is another problem.

References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions