Drop-in replacement for sw_vers that simplifies retrieving friendly names
in macOS (Ventura, Sonoma).
Currently, neither uname -a, sysctl, system_profiler or sw_vers
provide this information.
- π Fast β minimal overhead,
sw_name -releaseNamefunction executes in~ 5.7 ms, of~ 27 mstotal.1 - π Robust β accurate output through tests, robust regular expressions and parsing.
- π¦ Lightweight β self-contained, zero dependencies, uses POSIX
awk,sh(1245 bytes,65 lines).
Install it with:
$ brew install Neved4/tap/sw_namesw_name can be invoked in the following ways:
sw_name
sw_name -releaseName
sw_name -productName
sw_name -productVersion
sw_name -productVersionExtra
sw_name -buildVersionThe following options are available:
usage: sw_name [options]
Options:
-R, -releaseName, --releaseName
Prints release name (e.g.: Sonoma, Ventura, Monterey).
-n, -productName, --productName
Prints product name (e.g.: macOS, Mac OS X).
-v, -productVersion, --productVersion
Prints product version (e.g.: 12.1, 14.0).
-E, -productVersionExtra, --productVersionExtra
Prints info specific to certain releases (e.g: (a)).
-b, -buildVersion, --buildVersion
Prints the build version (e.g.: 23B81, 21A559).
Environment:
DARWIN_LICENSE
Specifies the path to a custom license file.
Example: DARWIN_LICENSE=path/to/license sw_name
Clone the repository:
git clone https://github.com/Neved4/sw_versAdd the following to your shell profile (e.g. .bash_profile, .zprofile,
.profile):
alias sw_vers='/path/to/sw_vers_name.sh'Then simply execute it:
$ sw_vers
ReleaseName: Sonoma
ProductName: macOS
ProductVersion: 14.5
BuildVersion: 23F79Then you can use sw_vers normally, with a new -releaseName flag to
access macOS friendly names.
Alternatively, if you prefer a concise function, you can add this to your shell profile:
sw_name() {
awk '/SOFTWARE LICENSE AGREEMENT FOR/ {
gsub(/.*(macOS|OS X) |\\|.*$0 /, "")
print
}' '/System/Library/CoreServices/Setup Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf'
}And then call the new command:
$ sw_name
Sonoma| Version | Supported |
|---|---|
macOS 14 |
Yes β |
macOS 13 |
Yes β |
macOS 12 |
Yes β |
macOS 11 |
Yes β |
macOS 10.15 |
Yes β |
macOS 10.14 |
Yes β |
macOS 10.13 |
Yes β |
macOS 10.12 |
Yes β |
OS X 10.11 |
Yes β |
OS X 10.10 |
Yes β |
OS X 10.9 |
Yes β |
Supported shells
sw_name uses macOS's /bin/sh by default, but you can run it with
other POSIX shells too:
dash /path/to/sw_name.sh| Shell | Version | Supported |
|---|---|---|
bash |
5.2.15 |
β Yes |
dash |
0.5.12 |
β Yes |
ksh93 |
93u+m/1.0.7 |
β Yes |
mksh |
59c |
β Yes |
oksh |
7.3 |
β Yes |
osh |
0.18.0 |
β Yes |
posh |
0.14.1 |
β No |
yash |
2.55 |
β Yes |
zsh |
5.9 |
β Yes |
Thanks to @0risc for testing legacy OS X versions.
sw_name is licensed under the terms of the MIT License.
See the LICENSE file for details.