Created
August 27, 2024 12:34
-
-
Save theevilbit/ffd978145a975b912be03759a44da748 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# Run the lsregister command and store the output in a variable | |
output=$(/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump) | |
# Use awk to parse the relevant sections | |
echo "$output" | awk ' | |
# When "CFBundleDisplayName" is found, store the app name | |
/CFBundleDisplayName/ { | |
app_name = substr($0, index($0, "=") + 2) | |
gsub(/[ \;"]+/, "", app_name) | |
} | |
# When "CFBundleIdentifier" is found, store the bundle identifier | |
/CFBundleIdentifier/ { | |
bundle_id = substr($0, index($0, "=") + 2) | |
gsub(/[ \;"]+/, "", bundle_id) | |
} | |
# When "claimed schemes" is found, store the schemes | |
/claimed schemes/ { | |
# Remove leading tabs and spaces | |
schemes = substr($0, index($0, ":") + 2) | |
gsub(/^[ \t]+/, "", schemes) | |
} | |
# If schemes are found and app_name and bundle_id are set, print the information | |
schemes && app_name && bundle_id { | |
print "App Name: " app_name | |
print "Bundle Identifier: " bundle_id | |
print "Claimed Schemes: " schemes | |
print "------------------------------------" | |
# Reset values for next application | |
schemes = "" | |
app_name = "" | |
bundle_id = "" | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment