Skip to content

Instantly share code, notes, and snippets.

@n1kk
Created March 10, 2019 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n1kk/eee6250052012fd35a9cc2dc2e9aba58 to your computer and use it in GitHub Desktop.
Save n1kk/eee6250052012fd35a9cc2dc2e9aba58 to your computer and use it in GitHub Desktop.
Prints the bundle identifier for a given app in macOS
#! /bin/bash
get_apps_bundle_id() {
local name=$1
[[ -z $name ]] && { return; }
if [ ! -d "$name" ]; then
name=/Applications/${name}.app
if [ ! -d "$name" ]; then
return;
fi
fi
local plist=${name}/Contents/Info.plist
if [ ! -f "$plist" ]; then
return;
fi
local id=$(/usr/libexec/PlistBuddy -c "print :CFBundleIdentifier" "$plist")
echo "$id"
}
print_bundle_id() {
local id=`get_apps_bundle_id "$1"`
echo "$1 -\> $id"
}
print_bundle_id "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment