Version info

Use Alfred to retrieve the version of macOS or any installed application.

— Binary Adventures

If you ever need to file a bug report or ask for support, it’s usually a good idea to include as many details as possible, including version numbers. You could look up the version number of an application by simply launching it and checking the About dialog. But why not automate things, and have Alfred do the searching for you?

For the operating system (i.e. macOS), we’ll use sw_vers to retrieve the name and verison:

echo -n `sw_vers -productName` `sw_vers -productVersion`

For applications, we’ll use defaults to read the CFBundleName and CFBundleShortVersionString from the app’s plist.

Here’s the full command:

echo -n `/usr/bin/defaults read {query}/Contents/Info.plist CFBundleName` `/usr/bin/defaults read {query}/Contents/Info.plist CFBundleShortVersionString`

A List Filter at the start of the workflow asks whether we want the OS’s version or an application. In case of the latter, a File Filter on /Applications provides us with a list of installed applications to choose from. Finally, the name and version are copied to the clipboard, ready to be pasted in your bug report!

Here’s is what the complete workflow looks like:

The packaged .alfredworkflow file is available here.