-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathreset-MS_VSC.sh
More file actions
97 lines (87 loc) · 2.01 KB
/
reset-MS_VSC.sh
File metadata and controls
97 lines (87 loc) · 2.01 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
## Reset MS VSC (Mac) - v1.2.6
## MIT License
## Copyright 2018 JakeNology
## Quick Execution
# curl -fkl https://raw.githubusercontent.com/jakenology/Scripts/master/reset-MS_VSC.sh | bash
## Set Global Variables
start=$SECONDS
username=$(stat -f%Su /dev/console)
version="1.2.4"
me=$(basename "$0")
logfile=~/Library/Logs/$me.log
today=$(date)
## Declare Arrays
pids=($(pgrep Electron))
list=(
~/Library/Preferences/com.microsoft.VSCode.helper.plist
~/Library/Preferences/com.microsoft.VSCode.plist
~/Library/Caches/com.microsoft.VSCode
~/Library/Caches/com.microsoft.VSCode.ShipIt/
~/Library/Application\ Support/Code
~/Library/Saved\ Application\ State/com.microsoft.VSCode.savedState/
~/.vscode/
)
## THIS IS WHERE ALL THE FUNCTIONS SHALL GO; DO NOT MODIFY BEYOND THIS POINT!!!
# Initialize the log file
initlog() {
echo $me started by USER $username on $today > $logfile
echo TASK >> $logfile
}
# Attempt to Kill Visual Studio Code
killapp() {
for pid in "${pids[@]}"; do
echo -e 'killing PID no:\t' $pid >> $logfile
kill -9 $pid
done
}
# Iterate and remove all app files... (except for a few)
removefiles() {
for item in "${list[@]}"; do
echo removing $item >> $logfile
rm -Rif "$item" >> $logfile
done
}
version() {
clear
echo -e 'VERSION:\t' $version
exit 0
}
main() {
initlog
killapp > /dev/null 2>&1
removefiles
duration=$(( SECONDS - start ))
echo Completed in $duration Seconds >> $logfile
}
verbose() {
main
cat $logfile
sleep 5
open $logfile
}
help () {
clear
echo -e 'USAGE:\n'
echo "Display the script's version:"
echo "$me --Version | -V"
}
## Check for USER Input
if [[ $# = 0 ]]; then
main
else
while [[ $# > 0 ]]; do
case "$1" in
*Version|*version|*V|*v)
version
;;
*verbose|*Verbose|*VB|*vb)
verbose
;;
*HELP|*help|*H|*h)
help
;;
esac
shift
done
fi