mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-30 02:44:42 +01:00
feat(hcloud): add hcloud_prompt_info function
Add a prompt function to display the current Hetzner Cloud context in the shell prompt, with support for detecting HCLOUD_TOKEN env var.
This commit is contained in:
parent
e076690551
commit
a22dca6ae2
2 changed files with 48 additions and 0 deletions
|
|
@ -127,3 +127,20 @@ alias hcdc='hcloud datacenter list'
|
|||
alias hcloc='hcloud location list'
|
||||
alias hcst='hcloud server-type list'
|
||||
alias hcit='hcloud image list --type system'
|
||||
|
||||
# Prompt function to display current hcloud context
|
||||
# Usage: add $(hcloud_prompt_info) to your PROMPT or RPROMPT
|
||||
function hcloud_prompt_info() {
|
||||
# Check if HCLOUD_TOKEN is set (overrides context)
|
||||
if [[ -n "$HCLOUD_TOKEN" ]]; then
|
||||
echo "${ZSH_THEME_HCLOUD_PREFIX=<hcloud:}${ZSH_THEME_HCLOUD_TOKEN_TEXT=HCLOUD_TOKEN}${ZSH_THEME_HCLOUD_SUFFIX=>}"
|
||||
return
|
||||
fi
|
||||
|
||||
# Get active context
|
||||
local context
|
||||
context=$(hcloud context active 2>/dev/null)
|
||||
[[ -n "$context" ]] || return
|
||||
|
||||
echo "${ZSH_THEME_HCLOUD_PREFIX=<hcloud:}${context}${ZSH_THEME_HCLOUD_SUFFIX=>}"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue