Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # Copyright (C) 2022 Uco Mesdag
- # Description: Set and unset ForkLift as the default file viewer instead of
- # the Finder.
- # Usage: forklift-default
- file=~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist
- # Remove entries to prevent duplicates
- plutil -convert xml1 $file
- sed -i ':a;N;s/\n/&/4;Ta;/com\.binarynights\.ForkLift-3/!{P;D};:b;N;s/\n/&/;Tb;d' $file
- sed -i ':a;N;s/\n/&/4;Ta;/com\.apple\.finder/!{P;D};:b;N;s/\n/&/;Tb;d' $file
- plutil -convert binary1 $file
- if [[ "$(defaults read -g NSFileViewer 2>/dev/null)" = "com.binarynights.ForkLift-3" ]]; then
- echo "Resetting FileViewer to Finder.."
- defaults delete -g NSFileViewer
- defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add '{LSHandlerContentType="public.folder";LSHandlerRoleAll="com.apple.finder";}'
- osascript -e 'tell app "System Events" to display notification "Finder is now the default file viewer again." with title "FileViewer changed"'
- else
- echo "Setting FileViewer to ForkLift.."
- defaults write -g NSFileViewer -string com.binarynights.ForkLift-3;
- defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add '{LSHandlerContentType="public.folder";LSHandlerRoleAll="com.binarynights.ForkLift-3";}'
- osascript -e 'tell app "System Events" to display notification "Forklift is now the default file viewer." with title "FileViewer changed"'
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement