Skip to content

Instantly share code, notes, and snippets.

@gregswift
Last active September 16, 2020 05:01
Show Gist options
  • Save gregswift/0105ca5c6233c01146dcc6e9041c32d2 to your computer and use it in GitHub Desktop.
Save gregswift/0105ca5c6233c01146dcc6e9041c32d2 to your computer and use it in GitHub Desktop.
terraform_ps1.bashrc
source terraform_ps1.sh
# Obviously manage your PS1 however you are gonna mange it... this is just an example
PS1="\u@\h \W \$(__terraform_ps1) $"
# Pull this from https://gist.github.com/gregswift/11ee552bc443e1051eef9454c833c07f
source colorize.bashrc
# In our repos we bootstrap the repos pulling terraform into the directory
# Technically you dont need to include this in the conditional checks
TF_PATH=./terraform
function __terraform_ps1()
{
if [ -x ${TF_PATH} ] && [ -d .terraform ]; then
workspace="$(command ${TF_PATH} workspace show 2>/dev/null)"
echo "($(colorize_tier ${workspace}))"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment