ambevar-dotfiles/.scripts/homeclean

85 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
set -- "$HOME/.cache/emacs/backups" \
"$HOME/.cache/emacs/elpa/archives" \
"$HOME/.cache/emacs/elpa/gnupg" \
"$HOME/.cache/emacs/ido.last" \
"$HOME/.cache/emacs/saveplace" \
"$HOME/.cache/mutt" \
"$HOME/.cache/rtorrent" \
"$HOME/.cache/qutebrowser" \
"$HOME/.cache/zsh" \
"$HOME/.cmus/autosave" \
"$HOME/.cmus/cache" \
"$HOME/.cmus/lib.pl" \
"$HOME/.cmus/playlist.pl" \
"$HOME/.cmus/queue.pl" \
"$HOME/.cmus/resume" \
"$HOME/.cmus/search-history" \
"$HOME/.config/gtk-2.0" \
"$HOME/.config/gtk-3.0" \
"$HOME/.config/ranger/bookmarks" \
"$HOME/.config/ranger/history" \
"$HOME/.config/ranger/tagged" \
"$HOME/.fehbg" \
"$HOME/.gtk-bookmarks" \
"$HOME/.lesshst" \
"$HOME/.local/share/newsbeuter" \
"$HOME/.local/share/qutebrowser" \
"$HOME/.local/share/webkit" \
"$HOME/.mpv/watch_later" \
"$HOME/.mtap.fuseiso" \
"$HOME/.pulse-cookie" \
"$HOME/.viminfo" \
"$HOME/.w3m" \
"$HOME/.zcompdump"
## POSIX can store only one list at a time. Here we rely on the fact there is no
## space in the file names.
RMLIST_CRITICAL="$HOME/.mutt.pwds.cpt $HOME/.ssh/"
echo "==> List of files to be removed."
echo "$@" | sed 's/ /\n/g'
echo
echo "==> List of files to be wiped."
echo "$RMLIST_CRITICAL" | sed 's/ /\n/g'
CHOICE="N"
echo
echo ":: Remember to close all applications for cleaning."
echo "==> Clean home? [y/N]"
read CHOICE
CHOICE="$(echo $CHOICE | tr [:lower:] [:upper:])"
if [ "$CHOICE" != "Y" ]; then
echo "Nothing done."
exit
fi
## Clean trash if possible.
echo
echo "==> Emptying trash."
if ! command -v trash-empty >/dev/null 2>&1; then
echo ":: 'trash-empty' not installed, you have to clean other drives manually."
rm -rvf "$HOME/.local/share/Trash"
else
trash-empty
fi
## Remove data.
echo
echo "==> Remove dotfiles."
rm -rvf "$@"
## Wipe data
echo
echo "==> Remove critical data."
if [ "$(echo "$HOME" | grep -c ' ')" -ne 0 ]; then
echo 'WARNING: $HOME contains spaces, skipping.'
else
shred -zuv $RMLIST_CRITICAL
# wipe -rdzp2 $RMLIST_CRITICAL
fi
echo
echo "==> Cleaning done."