Skip to content

Instantly share code, notes, and snippets.

@SamJUK
Created January 3, 2025 23:51
Show Gist options
  • Select an option

  • Save SamJUK/52edfb60dc37224dd0a7525e1ffeece2 to your computer and use it in GitHub Desktop.

Select an option

Save SamJUK/52edfb60dc37224dd0a7525e1ffeece2 to your computer and use it in GitHub Desktop.
P10k Custom Segments
#!/usr/bin/env zsh
# File: ~/.config/.p10k/prompt-hcloud_ctx.zsh
function prompt_hcloud_ctx() {
local _hcloud_context
[[ -z $_hcloud_context ]] && _hcloud_context=$(hcloud context list | awk '$1 ~ /^\*/ {print $2}')
[[ -n $_hcloud_context ]] || return
p10k segment -f red3 -i 'H' -t "$_hcloud_context"
}
#!/usr/bin/env zsh
# File: ~/.config/.p10k/prompt-magento-ver.zsh
function prompt_magento_version() {
_p9k_upglob 'composer.(json|lock)' && return
local dir=$_p9k__parent_dirs[$?]
local lock=$dir/composer.lock
local json=$dir/composer.json
if [[ -r $lock ]]; then
if ! _p9k_cache_stat_get $0 $lock; then
local v=$(grep -E -A1 "\"name\": \"magento/product-(community|enterprise)-edition\"" "$lock" 2> /dev/null | awk -F\" 'END{print $4}')
_p9k_cache_stat_set "$v"
fi
elif [[ -r $json ]]; then
if ! _p9k_cache_stat_get $0 $json; then
local v=$(grep -E 'magento/product-(community|enterprise)-edition' "$json" 2> /dev/null | awk -F\" '{print $4}')
_p9k_cache_stat_set "$v"
fi
fi
[[ -n $_p9k__cache_val[1] ]] || return
p10k segment -f orangered1 -i '' -t "${_p9k__cache_val[1]}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment