Open szhu opened 8 years ago
I accidentally associated some nonsense URL scheme with applications and would also like to remove those associations. So it would be really nice, if doti
would support that!
Reading the manpage, but can't find how to unset associations.
Having the same problem. How can these settings be removed?
FWIW Apple does not provide an API to reset/remove the default content handler for a UTI or the default handler for a URL scheme. However, one may specify a new bundle identifier in a followup duti command to set the the default handler to the original application or another application. The only way to reset to the default handlers otherwise is to use lsregister or a third-party tool to reset and rebuild the Launch Services database.
I wonder we can achieve the same effect by:
I haven't tested it, but I suspect that this will be able to remove custom associations (ones set in Open With…/duti
) but it might not be able to remove associations that apps have set in their Info.plist
file.
I had the same problem. To solve this, I had to manually (using PlistBuddy
) remove it.
In my example:
$ /usr/libexec/PlistBuddy -c "Print" \
> ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist
# Discover the array number of the entry I want to remove
# In my case: 23
$ /usr/libexec/PlistBuddy -c "Delete :LSHandlers:23" \
> ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist
This is not a good user experience. It would be nice if duty
could remove these entries for me.
Ps: Also, to discover the app registered to a given URL scheme, I need to manually use PlistBuddy
.
Same problem. I used duti
to change the default for public.shell-script
because I wanted script to start an editor so I could edit them, stupidly not realizing that I now made it harder to execute shell scripts.
I tried @rarylson procedure but unfortunately it doesn't change anything for me.
Wrote some script that can automaticly remove all vscode Dict instances. You can change it to any other app:
#!/bin/bash
# Path to the plist file
PLIST=~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist
# Backup the original plist file
cp "$PLIST" "${PLIST}.backup"
count_ls_handlers() {
/usr/libexec/PlistBuddy -c "Print :LSHandlers" "$PLIST" | grep "= Dict {" | wc -l | xargs
}
# Get the total number of LSHandlers entries
COUNT=$(count_ls_handlers)
OLD_COUNT=$(count_ls_handlers)
# Loop through the entries and find VSCode entries
for ((i = 0; i < COUNT; i++)); do
HANDLER=$(/usr/libexec/PlistBuddy -c "Print :LSHandlers:$i:LSHandlerRoleAll" "$PLIST" 2>/dev/null)
if [ "$HANDLER" == "com.microsoft.vscode" ]; then
echo "Removing VSCode handler at index $i"
/usr/libexec/PlistBuddy -c "Delete :LSHandlers:$i" "$PLIST"
COUNT=$((COUNT - 1)) # Decrease count as the list gets shorter
i=$((i - 1)) # Decrease index as next item shifts to current index
fi
done
NEW_COUNT=$(count_ls_handlers)
echo "Operation completed. $((OLD_COUNT - NEW_COUNT)) entries was removed"
I needed to restart system to make it work though
Suppose I have a file of the following type hierarchy:
I want
com.netscape.javascript-source
files to be opened by AppTwo, but I don't want to explicitly associate them with AppTwo. I just want to remove the exception so that they get handled the same way as the otherpublic.source-code
files.Is there something I can run along the lines of
duti -s NONE public.html all
to achieve this effect?