Skip to content

Instantly share code, notes, and snippets.

@GeneralD
Created February 8, 2018 03:10
Show Gist options
  • Save GeneralD/68ceca0f2b0719b3aa123630d190b494 to your computer and use it in GitHub Desktop.
Save GeneralD/68ceca0f2b0719b3aa123630d190b494 to your computer and use it in GitHub Desktop.
#!/usr/bin/env zsh
(){
local plistfile="$HOME/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist"
local i=0
while [[ $i != "false" ]]; do
[[ `/usr/libexec/PlistBuddy -c "Print :LSHandlers:$i" $plistfile 2>/dev/null` ]] || break
ext=`/usr/libexec/PlistBuddy -c "Print :LSHandlers:$i:LSHandlerContentTag" $plistfile 2>/dev/null`
app=`/usr/libexec/PlistBuddy -c "Print :LSHandlers:$i:LSHandlerRoleAll" $plistfile 2>/dev/null`
[[ $ext =~ ^[a-zA-Z0-9]+$ ]] && [ $app ] \
&& ! alias -s $ext 1>/dev/null && alias -s $ext="open -b ${app}"
((i++))
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment