Member-only story
Enable Terraform Autocomplete
Streamline Your Infrastructure as Code with Easy Setup Tips
Introduction
Enabling tab completion for Terraform commands can significantly improve your productivity by reducing the amount of typing required and helping to avoid typos in command names and options. Both Bash and Zsh, two of the most popular UNIX shells, support autocomplete features for Terraform. This guide will walk you through the steps to enable this functionality in your shell environment.
For Bash Users
To enable autocomplete for Terraform in Bash, follow these steps:
- Ensure a Bash Configuration File Exists: The Bash configuration file (
~/.bashrc
for Linux users and~/.bash_profile
for macOS users) is where you will add the script to enable autocomplete. First, check if the file exists by running:
touch ~/.bashrc
This command will create the file if it doesn’t exist or do nothing if the file already exists.
- Install the Autocomplete Package: Terraform includes an option to install autocomplete scripts for Bash. Run the following command to install the autocomplete feature:
terraform -install-autocomplete