-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfree
More file actions
executable file
·40 lines (32 loc) · 1.56 KB
/
free
File metadata and controls
executable file
·40 lines (32 loc) · 1.56 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
#!/bin/bash
# Colors
blue=$'\033[0;34m'
cyan=$'\033[1;96m'
reset=$'\033[0;39m'
# Avoid boring prefix in du/df/etc
cd "$HOME"
initial_used_space=$(df -h "$HOME" | grep -v 'Filesystem' | awk '{ printf("%f", $3) }')
echo "cleaning out some space..."
rm -rfv ~/Library/Caches/CloudKit
rm -rfv ~/Library/Caches/Google
rm -rfv ~/Library/Caches/com.apple.keyboardservicesd
rm -rfv ~/Library/Caches/com.apple.nsservicescache.plist
rm -rfv ~/Library/Caches/com.apple.parsecd
rm -rfv ~/Library/Caches/com.googlecode.munki.ManagedSoftwareCenter
rm -rfv ~/Library/Caches/com.hnc.Discord
rm -rfv ~/Library/Caches/com.hnc.Discord.ShipIt
rm -rfv ~/Library/Caches/com.microsoft.VSCode.ShipIt
rm -rfv ~/Library/Containers/com.docker.docker/*
rm -rfv ~/Library/Containers/*
rm -rfv ~/Library/Application\ Support/discord/Cache/*
rm -rfv ~/.Trash/*
rm -rfv ~/.cache/*
rm -rfv ~/Library/Developer/CoreSimulator/*
rm -rfv ~/Library/Application Support/Slack/Service Worker/CacheStorage/*
rm -rfv ~/Library/Application Support/Code/CachedData/*
echo "mmhm, refreshing!"
df -h . | grep --color=always -E "Size|Used|Avail|Capacity|[0-9]*\.*[0-9]*Mi|[0-9]*\.*[0-9]*Gi|[0-9]+\.*[0-9]+% |$"
final_used_space=$(df -h "$HOME" | grep -v 'Filesystem' | awk '{ printf("%f", $3) }')
freed_space=$(printf "%.1f" $(echo -e "${initial_used_space} - ${final_used_space}" | bc))
echo -e "${blue}\nFreed space: ${cyan}${freed_space}Gi${reset}"
echo -e "${blue}Pro tip: use ${cyan}GrandPerspective${blue} (GUI, available in the MSC) or ${cyan}ncdu${blue} (terminal, available with brew) to show a deep scan of your space.${reset}"