1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-30 09:40:09 +00:00
ohmyzsh/plugins/terraform-workspace-prompt
2023-04-10 22:27:50 -04:00
..
_terraform FEAT(terraform-workspace-prompt): Improved terraform plugins with support for agnoster theme prompt. 2023-04-10 22:27:50 -04:00
README.md FEAT(terraform-workspace-prompt): Improved terraform plugins with support for agnoster theme prompt. 2023-04-10 22:27:50 -04:00
terraform-workspace.plugin.zsh FEAT(terraform-workspace-prompt): Improved terraform plugins with support for agnoster theme prompt. 2023-04-10 22:27:50 -04:00

Terraform plugin to display workspace in prompt

Plugin for Terraform from Hashicorp, an infrastructure as code tool that allows for multi-cloud support, modularity, and the ability to plan and apply changes, making it easier to manage and provision infrastructure resources.

Features:

  • Completion for terraform
  • aliases
  • prompt function
  • Support for agnoster template

Structure:

.
├── README.md
├── plugins
    ├── _terraform
    └── terraform-workspace.plugin.zsh

Requirements

Installation:

Manual

  1. Clone the repository to your localspace
    • git clone https://github.com/ocontant/terraform-workspace.git
  2. Copy the plugins folder to ~/.oh-my-zsh/custom/plugins/terraform-workspace
    • cp -r plugins/terraform-workspace ~/.oh-my-zsh/custom/plugins/terraform-workspace
  3. Copy the themes folder to ~/.oh-my-zsh/custom/themes/agnoster
    • cp -r themes/agnoster ~/.oh-my-zsh/custom/themes/agnoster
  4. Add the plugin terraform-workspace to your plugins array section of your ~/.zshrc file
    • plugins=(... terraform-workspace)
  5. Add the theme terraform-agnoster to your theme section of your ~/.zshrc file

With Antigen

  1. Install Antigen:
    • curl -L git.io/antigen > ~/antigen.zsh
  2. Add antigen requirements to your ~/.zshrc file
  source ~/antigen.zsh 
  # Load Antigen configurations 
  antigen init ~/.antigenrc
  1. Create the file ~/.antigenrc and add the following content (I included my favorite bundle, feel free to add/remove):
  # Load oh-my-zsh library
  antigen use oh-my-zsh

  # Load bundles from the default repo (oh-my-zsh)
  antigen bundle git
  antigen bundle command-not-found
  antigen bundle docker

  # Load bundles from external repos
  antigen bundle zsh-users/zsh-completions
  antigen bundle zsh-users/zsh-autosuggestions
  antigen bundle zsh-users/zsh-syntax-highlighting
  antigen bundle zsh-users/zsh-history-substring-search
  
  # Load the terraform plugins and theme
  antigen bundle ocontant/terraform-workspace
  antigen theme ocontant/terraform-agnoster

  # Tell Antigen that you're done.
  antigen apply
  1. Add the theme terraform-agnoster to your theme section of your ~/.zshrc file
  2. Add the plugin terraform-workspace to your plugins array section of your ~/.zshrc file
    • plugins=(... terraform-workspace)

Prompt function

If you don't want to use oh-my-zsh agnoster theme, you can use this prompt to display the current Terraform workspace in your prompt.

  1. Create a bloc in your ~/.zshrc file:
# Terraform prompt
## Create 2 variables (feel free to customize the colors)
ZSH_THEME_TF_PROMPT_PREFIX="%{$fg[white]%}"
ZSH_THEME_TF_PROMPT_SUFFIX="%{$reset_color%}"

## Add the current Terraform workspace in your prompt by adding `"TF: ${__TERRAFORM_WORKSPACE_CACHE:gs/%/%%}"` to your `PROMPT` or `RPROMPT` variable.
## Example:
PROMPT="${PROMPT}>${ZSH_THEME_TF_PROMPT_PREFIX-[}${__TERRAFORM_WORKSPACE_CACHE:gs/%/%%}${ZSH_THEME_TF_PROMPT_SUFFIX-]}"