Skip to content

Instantly share code, notes, and snippets.

@natemccurdy
Last active February 27, 2023 16:16
Show Gist options
  • Save natemccurdy/8bb539b81c30b44685b07ca23e57c111 to your computer and use it in GitHub Desktop.
Save natemccurdy/8bb539b81c30b44685b07ca23e57c111 to your computer and use it in GitHub Desktop.
A Powerlevel10k prompt segment for your VAULT_ADDR
# Create a Powerlevel10k prompt segment that shows that value of $VAULT_ADDR if set.
function prompt_my_vault_addr() {
if [[ -n $VAULT_ADDR ]]; then
p10k segment -i '🔐' -f brightwhite -b blue -t "$VAULT_ADDR"
fi
}
# Add it to the right prompt.
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS+=my_vault_addr
# Only show it when running 'vault'.
typeset -g POWERLEVEL9K_MY_VAULT_ADDR_SHOW_ON_COMMAND='vault'
@natemccurdy
Copy link
Author

vault_addr segment

@natemccurdy
Copy link
Author

A more subtle color option:

function prompt_my_vault_addr() {
  if [[ -n $VAULT_ADDR ]]; then
    p10k segment -i 'LOCK_ICON' -r -f black -b cyan -t "$VAULT_ADDR"
  fi
}

green vault_addr

@natemccurdy
Copy link
Author

There's an actual Hashicorp Vault icon in the devicons/devicon project: devicons/devicon#1609

Powerlevel10k uses NerdFonts, which includes an unmaintained version of devicons (vorillaz/devicons).

The devicons/devicon project is actively maintained and has more icons, and NerdFonts is trying to migrate to the newer project, but that hasn't completed yet: ryanoasis/nerd-fonts#615

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment