brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: PlistBuddy reads one value from a macOS plist, like an app's version

macOS
~/tips/tip-macos-plistbuddy-app-version

/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" /Applications/Safari.app/Contents/Info.plist

Read a single key such as an app's version from a property list file.

Every Mac app has an Info.plist inside its bundle with its name, version and identifier. When a script needs just the version, PlistBuddy gets it without parsing XML yourself.

It lives outside your PATH, so call it by its full path. The -c option runs one command, and Print with a key prints that key’s value:

/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" /Applications/Safari.app/Contents/Info.plist

The colon in front of the key marks the top level of the file. For nested values you chain the keys with more colons, and the man page explains the full syntax for arrays and dictionaries.

A practical use: a small update check that compares the installed version of an app with what you expect, or a report that lists the versions of a handful of apps on a Mac. Swap in CFBundleIdentifier to get the bundle ID instead.

Leave out the key and Print dumps the entire file, which is a good way to see which keys exist.

Be careful with the other commands. Set, Add and Delete change the file, and changing a file inside an app bundle can break its code signature, after which macOS may refuse to open the app. On app bundles I’d stick to Print, and I’d test edits on a copy of a plist first.

Further reading: PlistBuddy.8 man page

More macOS tips System Settings > Accessibility > Hover Text > When using the pointer A Smart Folder in Notes collects notes by tag, checklist or date Type # in a Mac note to tag it, then filter by tag in the sidebar tmutil isexcluded ~/Projects/app/node_modules Crop an image in Preview by dragging a frame and clicking Crop All macOS tips (99) All topics

Link