Member-only story

Enable Terraform Autocomplete

Streamline Your Infrastructure as Code with Easy Setup Tips

Luca Berton
5 min readFeb 5, 2024

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:

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

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

--

--

Luca Berton
Luca Berton

Written by Luca Berton

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday

No responses yet