Created
March 10, 2019 23:12
-
-
Save n1kk/eee6250052012fd35a9cc2dc2e9aba58 to your computer and use it in GitHub Desktop.
Prints the bundle identifier for a given app in macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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