Last active
April 6, 2025 17:52
-
-
Save ScottJWalter/78e636c09137ab6797de9413feb95935 to your computer and use it in GitHub Desktop.
Powerlevel10k tweak to add OS version number to prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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