Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- #########
- #
- # searchURLHandlers.sh
- # Name : searchURLHandlers
- # Version : 2.0
- # Created : 2011-01-18
- # Modified : 2011-01-18
- #
- #########
- #
- # Search for each app known by Spotlight if a CFBundleURLTypes key
- # is present in Info.plist and displays if yes
- #
- #########
- #
- # Version history :
- #
- # 2011-01-18 1.0 : initial release
- # 2011-01-18 2.0 : added filters for apps without URLs Handlers and to clean output
- #
- #########
- PATH="/bin:/sbin:/usr/bin:/usr/sbin"
- export PATH
- VERSION="searchURLHandlers v2.0 2011-01-18"
- ERRORLOG="/tmp/searchURLHandleerror.log"
- PLISTBUDDY="/usr/libexec/PlistBuddy"
- OLDIFS=$IFS
- IFS=$(echo -en "\n\b")
- for i in $(mdfind "kMDItemContentTypeTree == "com.apple.application-bundle"" | grep app); do
- if [[ -f $i/Contents/Info.plist ]]; then
- NBARRAYS=$($PLISTBUDDY -c "print :CFBundleURLTypes" ${i}/Contents/Info.plist 2>$ERRORLOG | awk -F '=' '/CFBundleURLSchemes = /{print $2}' | wc -l)
- if [[ $NBARRAYS -gt 0 ]]; then
- echo "$i"
- for (( nb = 0; nb < $NBARRAYS; nb++ )); do
- $PLISTBUDDY -c "print :CFBundleURLTypes:$nb:CFBundleURLName" ${i}/Contents/Info.plist 2>$ERRORLOG
- $PLISTBUDDY -c "print :CFBundleURLTypes:$nb:CFBundleURLSchemes" ${i}/Contents/Info.plist 2>$ERRORLOG | egrep -v "{|}" | tr -d "\n" && echo
- done
- echo -e "\n"
- fi
- fi
- done
- rm $ERRORLOG
- IFS=$OLDIFS
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement