-
Notifications
You must be signed in to change notification settings - Fork 2
/
Reset Safari.sh
51 lines (37 loc) · 1.56 KB
/
Reset Safari.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
###
#
# Name: Reset Safari.sh
# Description: Resets all Safari user data to defaults for the currently
# logged-in user.
########## variable-ing ##########
loggedInUser=$(/usr/bin/stat -f%Su "/dev/console")
loggedInUserHome=$(/usr/bin/dscl . -read "/Users/$loggedInUser" NFSHomeDirectory | /usr/bin/awk '{print $NF}')
userLibrary="$loggedInUserHome/Library"
uuid=$(/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/awk '/Hardware UUID/ {print $NF}')
preferencesToReset=(
"$userLibrary/Caches/Metadata/Safari"
"$userLibrary/Caches/com.apple.Safari"
"$userLibrary/Caches/com.apple.WebKit.PluginProcess"
"$userLibrary/Cookies/Cookies.binarycookies"
"$userLibrary/Preferences/ByHost/com.apple.Safari.$uuid.plist"
"$userLibrary/Preferences/com.apple.Safari.LSSharedFileList.plist"
"$userLibrary/Preferences/com.apple.Safari.RSS.plist"
"$userLibrary/Preferences/com.apple.Safari.plist"
"$userLibrary/Preferences/com.apple.Safari.plistls"
"$userLibrary/Preferences/com.apple.WebFoundation.plist"
"$userLibrary/Preferences/com.apple.WebKit.PluginHost.plist"
"$userLibrary/Preferences/com.apple.WebKit.PluginProcess.plist"
"$userLibrary/PubSub/Database"
"$userLibrary/Safari"
"$userLibrary/Saved Application State/com.apple.Safari.savedState"
)
########## main process ##########
# Delete Safari preference files.
echo "Deleting Safari preference files to reset to system default..."
for safariPref in "${preferencesToReset[@]}"; do
if [ -e "$safariPref" ]; then
/bin/rm -rv "$safariPref"
fi
done
exit 0