Script snippet to determine if you are on an ARM Mac or not

Today I figured out a way to determine if the Mac you are on is an ARM Mac or not.

Usually, you’d use the arch command, but that may not return accurate information if your terminal app is running under Rosetta (for example, that’s the recommended way to install/run brew at the moment).

However, when downloading apps that have a separate ARM or Intel version, it is important to get the proper version. For example, I want the ARM version of Zoom.

#!/bin/zsh -f

ARCH=$(sysctl kern.version | awk -F'_' '/RELEASE/{print $2}')

if [[ "$ARCH" == "ARM64" ]]
then
	ARCH='arm64'
elif [[ "$ARCH" == "X86" ]]
then
	ARCH='i386'
else
	echo "Unknown arch returned: '$ARCH'" >>/dev/stderr 
	exit 2
fi

echo "$ARCH"
exit 0

You could also use this for Keyboard Maestro in an “IF” statement, for example.

This is also available as a gist.

(Crossposted to Keyboard Maestro forum.)

6 Likes