Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnwylie70/e9be899fdbf42250f035e2467719d0e7 to your computer and use it in GitHub Desktop.
Save johnwylie70/e9be899fdbf42250f035e2467719d0e7 to your computer and use it in GitHub Desktop.
Powerlevel 9k 10k Arm64 or x86 status segments on Apple Silicon M1 (zsh, ohmyzsh)
To customise your terminal or iTerm to identify if you are in a Rosetta or Arm64 Architecture terminal,
add the following code in your ~/.zshrc file before the Powerlevel 10k statements.
# MacOS Architecture detection
function prompt_architecture() {
arch_name="$(uname -m)"
if [ "${arch_name}" = "x86_64" ]; then
if [ "$(sysctl -in sysctl.proc_translated)" = "1" ]; then
p10k segment -b 7 -f 0 -t 'x86'
else
p10k segment -b 7 -f 0 -t 'x86'
fi
elif [ "${arch_name}" = "arm64" ]; then
p10k segment -b 7 -f 0 -i 'Arm64'
else
echo="?"
fi
}
...
ZSH_THEME="powerlevel10k/powerlevel10k"
etc....
Then open ~/.p10k.zsh and locate "POWERLEVEL9K_LEFT_PROMPT_ELEMENTS" and insert the custom segment.
# The list of segments shown on the left. Fill it with the most important segments.
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
# =========================[ Line #1 ]=========================
os_icon # os identifier
architecture # Arm or Rosetta? <------- ****** add this line ********
dir # current directory
vcs # git status
Then when you launch a new terminal it will show you what the terminal is running under.
You can also use unicode graphic icons if you prefer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment