-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclean-up
270 lines (192 loc) · 7.56 KB
/
clean-up
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
🗑️ MAC CLEANUP 🗑️
$commands to help clean up macbook
$Beware there may have some repeats
_______________________________________________________
#Find all empty files in home directory:
find ~ -empty
#Recursively Delete .DS_Store Files
sudo find . -type f -name '*.DS_Store' -ls -delete
#Purge memory cache
sudo purge
#Clear font cache
sudo atsutil databases -removeUser &&
atsutil server -shutdown &&
atsutil server -ping
#Deleting all .pyc file
sudo find . -path "*/*.pyc" -delete
#Deleting all .pyo files
sudo find . -path "*/*.pyo" -delete
#Deleting all ‘__pycache__' files
sudo find . -path "*/__pycache__" -type d -exec rm -r {} ';'
#Empty the Trash on all mounted volumes and the main HDD and clear Apple’s System Logs to improve shell startup speed
sudo alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; rm -rfv /private/var/log/asl/*.asl"
#Remove all cached content
sudo AssetCacheManagerUtil flushCache
#Delete All System Logs in OS X:
sudo rm -rf /private/var/log/*
#Delete QuickLook Caches
sudo rm -rf /private/var/folders/
#Remove Emacs
sudo rm -rf /usr/share/emacs/
#Use xcrun cli to delete unavailable simulators
xcrun simctl delete unavailable
#Use xcrun cli to delete simulators you don’t develop for example watchOS
xcrun simctl list devices | grep -E -i "watch" | grep -E -o "([A-Z0-9]+-){4}([A-Z0-9]+)" | xargs xcrun simctl delete
$$$ NPM $$$$
#Cleanup npm cache
npm cache clean --force
npm audit --audit-level=high;
npm install npm@latest -g --to upgrade;
npm install --cache /tmp/empty-cache --delete temperatry cache;
npm prune;
npm audit;
npm audit fix --force
$$$ RUBY $$$
$cleanup gem
gem cleanup
$$$ PYTHON $$$
#cleanup pip cache
rm -rfv ~/Library/Caches/pip
#Yarn
yarn cache clean;
yarn cache clean --force
#Docker
docker container rm -v;
docker image prune;
docker volume prune;
#brew
brew update && brew upgrade && brew cleanup
#Remove all the merged branches from a single project with this command:
git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d
#Removes all node_modules folders older than 4 months:
find . -name "node_modules" -type d -mtime +120 | xargs rm -rf
#Removes all node_modules folders:
find . -name "node_modules" -type d | xargs rm -rf
#Clean up CocoaPod caches:
rm -rf "${HOME}/Library/Caches/CocoaPods"
#Clean up various archives, logs, and derived data folders:
rm -rf ~/Library/Developer/Xcode/Archives;
rm -rf ~/Library/Developer/Xcode/DerivedData;
rm -rf ~~/Library/Developer/Xcode/iOS Device Logs/
#Combines Perl, AppleScript, and various tools to find duplicate entries in the Address Book application
osascript -e 'tell app "Address Book" to get the name of every person' | perl -pe 's/, /\n/g' | sort | uniq -d
#Update installed apps & clear caches
brew analytics off;
brew outdated;
brew update;
brew upgrade;
brew cask upgrade;
brew cleanup;
brew tap "homebrew/bundle";
rm -rf ~/Library/Caches/Homebrew
#You can create a symbolic link to the in ~/bin with
ln -s ~/Projects/quickpkg/quickpkg ~/bin
#Recursively Delete .DS_Store Files
sudo find . -type f -name '*.DS_Store' -ls -delete
#Delete caches:
sudo rm -rf ~/Library/Caches/*
#Delete caches
echo "cleaning ~/Library/Containers/$x/Data/Library/Caches/";
rm -rf ~/Library/Containers/$x/Data/Library/Caches/*;
echo "done cleaning ~/Library/Containers/$x/Data/Library/Caches"
#Update all brew related files
brew update && brew upgrade && brew cleanup
#Clear DNS Cache
sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder
#Empty the Trash on all mounted volumes and the main HDD
sudo rm -rfv /Volumes/*/.Trashes/;
sudo rm -rfv ~/.Trash/
#Clear Font Cache for Current User
atsutil databases -removeUser &&
atsutil server -shutdown &&
atsutil server -ping
#Clear System Log Files
sudo rm -rfv /private/var/log/asl/;
sudo rm -rfv /Library/Logs/DiagnosticReports/;
sudo rm -rfv /Library/Logs/Adobe/;
sudo rm -rfv ~/Library/Containers/com.apple.mail/Data/Library/Logs/Mail/*
sudo rm -rfv ~/Library/Logs/CoreSimulator/
#Clear Adobe Cache Files
sudo rm -rfv ~/Library/Application\\ Support/Adobe/Common/Media\\ Cache\\ Files/*
#Cleanup iOS Applications
rm -rfv ~/Music/iTunes/iTunes\\ Media/Mobile\\ Applications/*
#Remove iOS Device Backups
sudo rm -rfv ~/Library/Application\\ Support/MobileSync/Backup/*
#Cleanup XCode Derived Data & Archives
sudo rm -rfv ~/Library/Developer/Xcode/DerivedData/*
sudo rm -rfv ~/Library/Developer/Xcode/Archives/*
sudo rm -rfv ~/Library/Developer/Xcode/iOS Device Logs/*
#Purge inactive memory
sudo purge
#Purge all node_module folders from your workspace if you have multiple node projects on your system you want to clean up:
find . -name "node_modules" -type d -exec rm -rf '\{\}' +
#Clear XCode caches
xcrun simctl delete unavailable
#Updated all outdated packages installed through the Mac app store
mas upgrade{\field{\*\fldinst{HYPERLINK "https://mail.google.com/mail/u/0/#inbox"}}{\fldrslt https://mail.google.com/mail/u/0/#inbox}}
#Cleanup pip cache
rm -rfv ~/Library/Caches/pip
#Delete trash
rm -rdf ~/.Trash/*
_____________
#Ask for the administrator password upfront
sudo -v
#Update all brew related files
brew update && brew upgrade && brew cleanup
#Clear DNS Cache
sudo dscacheutil -flushcache &&
sudo killall -HUP mDNSResponder
#Empty the Trash on all mounted volumes and the main HDD\
sudo rm -rfv /Volumes/*/.Trashes/;
sudo rm -rfv ~/.Trash/
#Clear Font Cache for Current User
atsutil databases -removeUser &&
atsutil server -shutdown &&
atsutil server -ping
#Recursively Delete .DS_Store Files
sudo find . -type f -name '*.DS_Store' -ls -delete
#Update installed apps & clear caches
brew analytics off;
brew outdated;
brew update;
brew upgrade;
brew cask upgrade;
brew cleanup;
brew tap "homebrew/bundle";
rm -rf ~/Library/Caches/Homebrew
#Clear System Log Files
sudo rm -rfv /private/var/log/asl/;
sudo rm -rfv /Library/Logs/DiagnosticReports/;
sudo rm -rfv /Library/Logs/Adobe/;
rm -rfv ~/Library/Containers/com.apple.mail/Data/Library/Logs/Mail/*
rm -rfv ~/Library/Logs/CoreSimulator/;
#Clear Adobe Cache Files
sudo rm -rfv ~/Library/Application\\ Support/Adobe/Common/Media\\ Cache\\ Files/*
#Cleanup iOS Applications
rm -rfv ~/Music/iTunes/iTunes\\ Media/Mobile\\ Applications/*
#Remove iOS Device Backup
rm -rfv ~/Library/Application\\ Support/MobileSync/Backup/*
#Cleanup XCode Derived Data and Archives
rm -rfv ~/Library/Developer/Xcode/DerivedData/*
rm -rfv ~/Library/Developer/Xcode/Archives/*
rm -rfv ~/Library/Developer/Xcode/iOS Device Logs/*
if type "xcrun" &>/dev/null; then
echo 'Cleanup iOS Simulators...'
osascript -e 'tell application "com.apple.CoreSimulator.CoreSimulatorService" to quit'
osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl shutdown all
xcrun simctl erase all
fi
#Purge inactive memory
sudo purge
#Clear Xcode caches
xcrun simctl delete unavailable
#Update conda python environment
conda update --all
#These folder and files are generated by python. You should add these to your VCS’s ignore file. But if you need to clean these manually, you can do with the command below:
find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
#This command will remove all files that end with .pyc and __pycache__ folder recursively in the current directory. If you are using this command a lot, you should think about adding it to your *sh alias list.
#Note: For Python 3, you only need to remove __pycache__ folder because .pyc files are inside them.
#Alternative: You can prevent the generation of the file in the development using the environment variable below:
export PYTHONDONTWRITEBYTECODE=""