Home > Back-end >  How can I load zsh settings conditionally based on CPU?
How can I load zsh settings conditionally based on CPU?

Time:03-27

I have my .zshrc file stored on a cloud service and have symbolic links that reference it on both of my Macs. One is M1 based on the other Intel. I need a setting that is slightly different on each machine because of the different CPU types. How can I set these settings only if the CPU is correct?

CodePudding user response:

You can use the output of uname -m, like this:

#!/bin/zsh

if [ $(uname -m) = "arm64" ]; then
  echo "ARM detected"
else
  echo "Intel detected"
fi

and place the actual stuff you want to happen instead of just printing the detected processor/architecture

  • Related