Skip to content

Instantly share code, notes, and snippets.

@ScottJWalter
Last active April 6, 2025 17:52
Show Gist options
  • Save ScottJWalter/78e636c09137ab6797de9413feb95935 to your computer and use it in GitHub Desktop.
Save ScottJWalter/78e636c09137ab6797de9413feb95935 to your computer and use it in GitHub Desktop.
Powerlevel10k tweak to add OS version number to prompt
# STEP1: in ~/.p10k.zsh, find and alter:
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
os_icon
os_version # ADD THIS LINE
...
)
# STEP2: Still in ~/.p10k.zsh, after the `typeset` you just edited,
# add the following:
function prompt_os_version() {
p10k segment -t $(lsb_release -r | awk '{print $2}') -f white
###
# alternative method:
# while IFS= read -r line; do
# key=${line%%=*}
# value=${line#*=}
# if [[ "$key" == "VERSION_ID" ]]; then
# p10k segment -e -t "$value" -f white
# fi
# done < "/etc/os-release"
###
}
function instant_prompt_os_version() {
# prompt_os_version
}
# STEP3: reload shell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment