commit e3d4673abeb8029da0cd472ffcc7654201063c85
parent 73b4f7b0f55919201dfd51e3db0a85fe7cbdcf46
Author: Alex Balgavy <alex@balgavy.eu>
Date: Thu, 19 May 2022 20:06:14 +0200
trash: allow single-key confirmation with stty+dd
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/scripts/trash b/scripts/trash
@@ -8,7 +8,10 @@ PARAMS=""
trash_empty() {
printf "Empty the trash? [y/n] "
- read -r conf; case "$conf" in
+ stty raw && conf="$(dd bs=1 count=1 2>/dev/null)" && stty -raw
+ printf "\n"
+
+ case "$conf" in
Y|y)
find "${TRASHDIR:?}" -delete
printf "Deleted all items in the trash.\n"
@@ -22,7 +25,10 @@ trash_empty() {
trash_empty_secure() {
printf "Securely empty the trash? [y/n] "
- read -r conf; case "$conf" in
+ stty raw && conf="$(dd bs=1 count=1 2>/dev/null)" && stty -raw
+ printf "\n"
+
+ case "$conf" in
Y|y)
command -v shred >/dev/null 2>&1 || { printf "Please install shred (1) to empty trash securely.\n" >&2 && exit 1; }
find "${TRASHDIR:?}" -type f -exec shred -uz {} +