Advertisement
adamchilcott

nukeSafari.sh

Nov 20th, 2017
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.20 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Reset Safari 10 for current user. Developed and tested under OS X 10.11.6 El Capitan.
  4.  
  5. # Backup bookmarks to Desktop, exiting if unsuccessful
  6. cp -v ~/Library/Safari/Bookmarks.plist ~/Desktop/Bookmarks-`date +%Y%m%d%H%M%S`.plist
  7. if [[ $? -ne 0 ]]; then exit 1; fi
  8.  
  9. # Delete main Safari data directory
  10. rm -rfv ~/Library/Safari
  11.  
  12. # Delete caches
  13. rm -rfv ~/Library/Caches/com.apple.Safari
  14. rm -rfv ~/Library/Caches/com.apple.Safari.SearchHelper
  15. rm -rfv ~/Library/Caches/com.apple.safaridavclient
  16. rm -rfv ~/Library/Caches/com.apple.WebKit.PluginProcess
  17. rm -rfv ~/Library/Caches/Metadata/Safari
  18. rm -rfv ~/Library/Caches/SafariNotificationAgent
  19. rm -rfv ~/Library/Caches/com.apple.commerce.safari/SafariLibrary
  20.  
  21. # Delete cookies
  22. rm -rfv ~/Library/Cookies/Cookies.binarycookies
  23. rm -rfv ~/Library/Cookies/com.apple.safari.cookies
  24. rm -rfv ~/Library/Cookies/com.apple.CaptiveNetworkAssistant.binarycookies
  25. rm -rfv ~/Library/Cookies/com.apple.Safari.SafeBrowsing.binarycookies
  26. rm -rfv ~/Library/Cookies/com.apple.Safari.SearchHelper.binarycookies
  27.  
  28. # Delete preferences
  29. rm -rfv ~/Library/Preferences/com.apple.Safari.LSSharedFileList.plist
  30. rm -rfv ~/Library/Preferences/com.apple.Safari.RSS.plist
  31. rm -rfv ~/Library/Preferences/com.apple.Safari.plist
  32. rm -rfv ~/Library/Preferences/com.apple.Safari.Extensions.plist
  33. rm -rfv ~/Library/Preferences/com.apple.WebFoundation.plist
  34. rm -rfv ~/Library/Preferences/com.apple.WebKit.PluginHost.plist
  35. rm -rfv ~/Library/Preferences/com.apple.WebKit.PluginProcess.plist
  36. rm -rfv ~/Library/Preferences/com.apple.commerce.safari.plist
  37.  
  38. # Delete saved state
  39. rm -rfv ~/Library/Saved\ Application\ State/com.apple.Safari.savedState
  40.  
  41. # Delete RSS feeds subscribed in Safari or Mail
  42. # More info on PubSub database and command:
  43. # http://krypted.com/mac-os-x/managing-mail-and-safari-rss-subscriptions-from-the-command-line/
  44. rm -rfv ~/Library/PubSub/Database
  45.  
  46. # Delete yet more Safari data (cannot find any definitive documentation on this directory)
  47. rm -rfv ~/Library/WebKit/com.apple.Safari
  48.  
  49. # Delete SharedFileList
  50. rm -rfv ~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/com.apple.safari.sfl
  51.  
  52. # Delete LSOs / Flash cookies
  53. rm -rfv ~/Library/Caches/Adobe/Flash\ Player
  54.  
  55. # Clear file quarantine database (i.e., list of downloaded files)
  56. # More info: http://osxdaily.com/2012/07/12/list-download-history-mac-os-x/
  57. sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'
  58.  
  59. # Delete QuickTime cache
  60. rm -rfv ~/Library/Caches/QuickTime
  61.  
  62. printf "\n\n\033[1;32mSafari cleanup complete.\n\n\033[1;31mThe contens of /Library/Internet Plug-Ins and ~/Library/Internet Plug-Ins\nwill appear below after pressing Enter. Check output for unwated plugins.\nPreserve Quartz Composer.webplugin & Default Browser.plugin at a minimum.\033[0m\n\n"
  63.  
  64. read -p "Press Enter to continue."
  65.  
  66. # List contents of /Library/Internet Plug-Ins and ~/Library/Internet Plug-Ins
  67. ls -A /Library/Internet\ Plug-Ins ~/Library/Internet\ Plug-Ins
  68.  
  69. #############
  70. # START NOTES
  71. #############
  72.  
  73. ## Reference:
  74. ## <https://tinyapps.org/blog/mac/201702110700_reset_safari_10.html>
  75.  
  76. ###########
  77. # END NOTES
  78. ###########
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement