commit c6b1279c86e7967d166b06daa4863a69668a5944 parent 897182da1d5ce802e3140b5d26fc5c2aca7d80e8 Author: regexghost <regexghost@protonmail.com> Date: Thu, 7 May 2026 15:53:34 +0100 added trash script Diffstat:
| M | terminal-scripts/Makefile | | | 1 | + |
| A | terminal-scripts/rm-trash.sh | | | 41 | +++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/terminal-scripts/Makefile b/terminal-scripts/Makefile @@ -4,6 +4,7 @@ normal: mkdir -p ${BIN} cp cmpfolder.sh ${BIN}/cmpfolder cp hashfolder.sh ${BIN}/hashfolder + cp rm-trash.sh ${BIN}/rm-trash gcc -o directory_bookmarks directory_bookmarks.c mv directory_bookmarks ${BIN}/directory_bookmarks cp github_latest_release.sh ${BIN}/github_latest_release diff --git a/terminal-scripts/rm-trash.sh b/terminal-scripts/rm-trash.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +# wrapper script around the rm, and trash-cli commands + +command="trash-put" +dialog="rm: Trash" + +if [ "$1" = "-p" ]; then + shift + command="/usr/bin/rm" + dialog="rm: Delete (Permanently)" +else + if ! which trash-put > /dev/null; then + echo "trash-cli not installed" + exit 1 + fi +fi + +for arg; do + filename="$arg" + + # Refuse to delete / or ~ + if [ "$filename" = "$HOME" ] || [ "$filename" = "/" ]; then + echo "Refusing to delete" + exit + fi + + ! [ -e "$filename" ] && echo "File/Directory doesn't exit" && continue + if [ -d "$filename" ]; then + if [ -z "$(ls -"$filename")" ]; then + read -p "${dialog} ${filename} (empty dir) (y/N) " confirm + else + read -p "${dialog} ${filename} (non-empty dir) (y/N) " confirm + fi + [ "$uservar" = "y" ] && "$command" -- "$filename" + continue + fi + + read -p "${dialog} ${filename} (y/N) " confirm + [ "$confirm" = "y" ] && "$command" -- "$filename" +done