把这两个函数定义放入~/.profile
function tmc() {
for d in $(mount |grep Time|awk '{print $3}'); do
diskutil umount "$d HD";
done
before=$(df -hl /System/Volumes/Data |awk '{print $3}' |tail -n1)
count=0
for snapshot in $(tmutil listlocalsnapshots /|awk -F. '{print $4}');do
let 'count++'
echo "delete snapshot $snapshot"
tmutil deletelocalsnapshots $snapshot;
done
after=$(df -hl /System/Volumes/Data |awk '{print $3}' |tail -n1)
if [[ $count -ne 0 ]]; then
echo "Total $count snapshot(s) deleted, Size change: $before ===> $after"
else
echo "No snapshot deleted"
fi
}
function tml() {
tmutil listlocalsnapshots /|awk -F. '{print $4}'
}
然后执行 . ~/.profile
之后就可以用命令tml
列出所有的快照列表,用tmc
清空所有的备份快照