I stole the emacs cleanings from DebianJoe (so, thank you DJ).
At first I thought it would be better to run it as root, but since I always launch bleachbit with sudo I tried to do something similar here. Obviously better ways to do what I had in mind, but as for printfile: it works for me, do whatever you want with it.
I don't know, a better version of this could become 'bbqmaid'? :)
Code: Select all
#!/bin/bash
clean_pkg()
{
echo "
Cleaning packages..."
sudo apt-get clean > /dev/null 2>&1
sudo apt-get autoclean > /dev/null 2>&1
sudo apt-get autoremove > /dev/null 2>&1
}
clean_cache()
{
echo "
Cleaning cache..."
sudo rm -rf /var/cache/apt/archives/*
sudo rm -rf /var/cache/apt-listbugs/*
}
clean_logs()
{
echo "
Cleaning logs..."
sudo rm -rf /var/log/Xorg.0.log.*
sudo rm -rf /var/log/dmesg.*
sudo rm -rf /var/log/cups/*
}
clean_emacsbak()
{
echo "
Cleaning emacs backups..."
backs=$(find ~/ -name "*~" -print0 | xargs -0)
dotbacks=$(find ~/ -name ".*~" -print0 | xargs -0)
sharpbacks=$(find ~/ -name "#*#" -print0 | xargs -0)
if [ -n "$backs" ]; then
find ~/ -name "*~" -exec rm -i {} \;
fi;
if [ -n "$dotbacks" ]; then
find ~/ -name ".*~" -exec rm -i {} \;
fi;
if [ -n "$sharpbacks" ]; then
find ~/ -name "#*#" -exec rm -i {} \;
fi;
}
echo "
###########################################
# frenchmaid #
# Script for cleaning the system #
# Use -y to run all the cleanings at once #
###########################################"
sudo -v # gets user password for next sudos
if [ "$1" == "-y" ]; then
clean_pkg
clean_cache
clean_logs
clean_emacsbak
else
read -n1 -p '
Clean packages? (y/n) '
if [ $REPLY = 'y' ]; then
clean_pkg
fi
read -n1 -p '
Clean cache? (y/n) '
if [ $REPLY = 'y' ]; then
clean_cache
fi
read -n1 -p '
Clean logs? (y/n) '
if [ $REPLY = 'y' ]; then
clean_logs
fi
read -n1 -p '
Clean emacs backups? (y/n) '
if [ $REPLY = 'y' ]; then
clean_emacsbak
fi
fi
echo "
System cleaned
"