-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(How to) Add right prompt element for processor architecture? #1635
Comments
Add this to typeset -g my_arch=$(/usr/bin/arch)
case $my_arch in
i386|x86_64)
my_arch+=' (Rosetta)'
if [[ -f /usr/local/homebrew/bin/brew ]];
eval "$(/usr/local/homebrew/bin/brew shellenv)"
alias brew='/usr/local/homebrew/bin/brew'
fi
;;
arm64)
my_arch+=' (Native)'
if [[ -f /opt/homebrew/bin/brew ]];
eval "$(/opt/homebrew/bin/brew shellenv)"
alias brew='/opt/homebrew/bin/brew'
fi
;;
*)
my_arch+=' (Unknown)'
;;
esac
function prompt_my_arch() {
p10k segment -b yellow -f red -t ${my_arch//\%/%%}
} Then add You can customize how P.S. I haven't tested this code. |
Thanks much! I had much of it figured out after going back through the readme, but couldn't get it to display. I didn't realize that p10k parsed the For anyone who references this in the future, here's the final addition to my .zshrc: ### Autodetect architecture (and set `brew` path)
if [[ "$(sysctl -a | grep machdep.cpu.brand_string)" == *Apple* ]]; then
archcheck=$(/usr/bin/arch)
typeset -g archcheck
case $archcheck in
arm64)
archcheck+=' (Native)'
if [[ -f /opt/homebrew/bin/brew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
alias brew='/opt/homebrew/bin/brew'
fi
;;
i386|x86_64)
archcheck+=' (Rosetta)'
if [[ -f /usr/local/homebrew/bin/brew ]]; then
eval "$(/usr/local/homebrew/bin/brew shellenv)"
alias brew='/usr/local/homebrew/bin/brew'
fi
;;
*)
archcheck+=' (Unknown)'
;;
esac
# add arch to p10k
function prompt_my_arch() {
p10k segment -f 250 -i '💻' -t "${archcheck//\%/%%}"
}
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS+=my_arch # to specify location, modify ~/.p10k.zsh
fi |
It would be helpful to have a reminder whether I'm working in a rosetta emulated terminal or a native one. Is there a way to add architecture to the right prompt?
Currently I have an
archcheck
function that is called whenever I start a new zsh session, but I'd like a more persistent reference:I don't want the full functionality in p10k (the majority of it does not make sense), but just having the output of
/usr/bin/arch
oruname -p
in the right prompt would be very useful! Thanks!The text was updated successfully, but these errors were encountered: