-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrash-empty
executable file
·55 lines (42 loc) · 1.08 KB
/
trash-empty
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh
source "$HOME/.bin/libs/_trash.sh"
# Args:
ALL=false
ISEMPTY=false
_tmenu() { tmenu -ms "$@"; }
[ -d "$TrashDir/files" ] || {
printf "%s\n" "The Trash Folder does not exits!"
exit 0
}
[ -z "$(ls $TrashDir/files)" ] && {
printf "%s\n" "The Trash Folder is empty!"
exit 0
}
main() {
$ISEMPTY && { exit 2; }
$ALL && { empty; exit 0; }
_tmenu <(listFiles) >( \
filenameFromLine | while read i; do delPerm "$i"; done; )
}
_usage() {
echo "$0 [options]"
echo "Use 'tmenu' to select trashed files to permanently delete"
echo ""
echo "options:"
echo " -?, --is-empty Chech if empty, exits with 0 is empty and 2 if not"
echo " --all Permanently delete all trashed files"
echo " -h, --help print this message"
}
# Read arguments
POSITIONAL=()
while [[ $# -gt 0 ]]; do
case $1 in
# --print|-p) PRINT=true ;;
-?|--is-empty) ISEMPTY=true ;;
--all) ALL=true ;;
-h|--help) _usage; exit 0 ;;
-*) echo "Invalid option '$1'" > /dev/stderr; exit 1 ;;
*) POSITIONAL+=("$1") ;;
esac; shift;
done
main "${POSITIONAL[@]}"