Last active
March 20, 2025 16:11
-
-
Save mjmenger/038fcf3f4ff6a4f3770eb36b7dae9f72 to your computer and use it in GitHub Desktop.
bash aliases I like to have available
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' | |
# Conditionally alias python to python3 if python is not defined and python3 is installed | |
if ! command -v python &> /dev/null && command -v python3 &> /dev/null; then | |
alias python='python3' | |
fi | |
# 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