Skip to content

Instantly share code, notes, and snippets.

@mjmenger
Last active May 11, 2024 16:14
Show Gist options
  • Save mjmenger/038fcf3f4ff6a4f3770eb36b7dae9f72 to your computer and use it in GitHub Desktop.
Save mjmenger/038fcf3f4ff6a4f3770eb36b7dae9f72 to your computer and use it in GitHub Desktop.
bash aliases I like to have available
# Terraform aliases
# adding time to the commands because I'm very interested
# in how long these activities take with more complex builds
# across disparate platforms
alias tfi='terraform init'
alias tfp='time terraform plan'
alias tfa='time terraform apply'
alias tfaa='time terraform apply -auto-approve '
alias tfd='time terraform destroy'
alias tfda='time terraform destroy -auto-approve '
alias twl='terraform workspace list '
alias tws='terraform workspace select '
alias twn='terraform workspace new '
alias tfoj='terraform output --json '
alias tgi='terragrunt init '
alias tgp='terragrunt plan '
alias tga='time terragrunt apply '
alias tgaa='time terragrunt apply -auto-approve '
alias tgd='terragrunt destroy '
alias tgda='time terragrunt destroy -auto-approve '
alias tgra='time terragrunt run-all apply '
alias tgra1='time terragrunt run-all apply --terragrunt-parallelism 1 '
alias tgrd='time terragrunt run-all destroy '
alias tgrd1='time terragrunt run-all destroy --terragrunt-parallelism 1 '
# Terraform switch aliases
alias tsw='tfswitch -b ~/bin/terraform '
alias mya='source ~/ansible2.15/bin/activate'
# command prompt
# PS1="\[\e[32m\]\u\[\e[m\]@\[\e[32m\]\h\[\e[m\]:\[\e[32m\]\W\[\e[m\]\[\e[34m\]\`parse_git_branch\`\`parse_tf_workspace\`\[\e[m\]\[\e[32m\]\$\[\e[m\] "
PS1="\[\e[32m\]\u\[\e[m\]@\[\e[32m\]\h\[\e[m\]:\[\e[32m\]\W\[\e[m\]\[\e[34m\]\`parse_git_branch\`\[\e[m\]\[\e[32m\]\$\[\e[m\] "
# get current branch in git repo
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (g:\1)/'
}
# get current workspace in terraform repo
parse_tf_workspace() {
[ -d ".terraform" ] && terraform workspace list 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (t:\1)/'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment