Powerlevel9k / powerlevel9k

Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
https://github.com/romkatv/powerlevel10k
MIT License
13.46k stars 947 forks source link

Expanding ZSH prompt with current Terraform workspace name #1354

Open rafilkmp3 opened 5 years ago

rafilkmp3 commented 5 years ago

Hi, I would like a segment for terraform workspace, here we have the plugin for zsh.

https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/terraform

to be able to do something like POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=('os_icon' 'todo' 'dir' 'vcs' 'terraform')

fishpen0 commented 4 years ago

Here's a simple custom one you can drop in your .zshrc:

zsh_terraform() {
  # break if there is no .terraform directory
  if [[ -d .terraform ]]; then
    local tf_workspace=$(/usr/local/bin/terraform workspace show)
    echo -n "$tf_workspace"
  fi
}

# Terraform Segment
POWERLEVEL9K_CUSTOM_TERRAFORM="zsh_terraform"
POWERLEVEL9K_CUSTOM_TERRAFORM_BACKGROUND=057
POWERLEVEL9K_CUSTOM_TERRAFORM_FOREGROUND=015

# Add terraform segment to your prompt
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_terraform)