12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- dir_trash="${HOME}/.local/share/Trash/files/"
- archive_temp="/tmp/random.trash"
- silent="1"
- HELP(){
- cat <<EOF
- USAGE: trash [OPTION]
- Trash is a non-interactive command line utility that cleans the system's trash.
- OPTIONS
- -q, --quiet
- Quiet, ideal for use in cron or halt/boot of your system.
- -h, --help
- Show this Help.
- Author Jefferson 'Slackjeff' Rocha
- EMAIL BUGS: < root@slackjeff.com.br >
- WEB: < https://notabug.org/jeffersonrocha/trash >
- EOF
- return 0
- }
- size_archives(){
- cd ${dir_trash} 2>/dev/null && du -hs | sed 's/.$//'> ${archive_temp}
- if [ -e "/tmp/random.trash" ]; then
- echo -e "\033[34;1mTotal Size:\033[m
- $(cat /tmp/random.trash)
- ----------------------------------"
- fi
- rm "${archive_temp}" 2>/dev/null
- }
- case $1 in
- -q|--silent)
- silent="0"
- ;;
- -h|--help)
- HELP
- exit 0
- ;;
- esac
- if [ "$silent" = "1" ]; then
- size_archives
- quiet="v"
- fi
- if [ -d ${dir_trash} ]; then
- (
- cd ${dir_trash} && rm -rf"$quiet" -- * 2>/dev/null
- [ "$silent" = "1" ] && echo -e "\033[31;1mSucessful.\033[m"
- )
- else
- echo "Directory '${dir_trash}' not found in system!"
- fi
|