summary refs log tree commit diff
path: root/bin/trash
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2026-02-10 12:32:48 +0100
committerRobert Günzler <r@gnzler.io>2026-02-10 12:41:25 +0100
commit63feeb9f369fc6176e85c1c2d8fcc863caad1946 (patch)
tree41cd5d2d1ec36e74e464caab722cc9b460153f04 /bin/trash
parent5bd0a4aca65ecb9818ef1285982d160b6b6ff665 (diff)
start new
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'bin/trash')
-rwxr-xr-xbin/trash88
1 files changed, 0 insertions, 88 deletions
diff --git a/bin/trash b/bin/trash
deleted file mode 100755
index 5a040cb..0000000
--- a/bin/trash
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/bin/sh
-
-set -e
-[ -n "$DEBUG" ] && set -x
-
-rmbin=/bin/rm
-
-TRASH="$HOME/.trash"
-if [ ! -d "$TRASH" ]; then
-	mkdir -p "$TRASH"
-fi
-
-ls_trash() {
-	# shellcheck disable=SC2068
-	fd -H . "${TRASH:?}" $@
-}
-
-empty_trash() {
-	if [ ! -d "$TRASH" ] || [ -z "$(ls_trash)" ]; then
-		exit 0
-	fi
-	echo " +++ trash +++"
-	ls_trash
-	read -r yn
-	if [ "$yn" = "y" ]; then
-		printf ' +++ removing everything under %s (%d)... ' "$TRASH" "$(fd . "${TRASH:?}" | wc -l)"
-		ls_trash -x $rmbin -r
-		echo 'done.'
-	fi
-}
-
-install_auto_empty() {
-	case "$SHELL" in
-		*zsh) logoutfile="$ZDOTDIR/.zlogout" ;;
-		*bash) logoutfile="$HOME/.bash_logout" ;;
-		*)
-			echo "unknown shell $SHELL" 1>&2
-			exit 1
-			;;
-	esac
-	cat >"$logoutfile" <<EOF
-# auto-empty-trash routine of $0
-yes | $0 --empty
-EOF
-}
-
-ask() {
-	r=$(printf 'yes\nno\n' | MENU_PROMPT="󰩹 delete $1" menu)
-	[ "${r}" = "yes" ] && return 0
-	return 1
-}
-
-interactive=${TRASH_ASK:-}
-trashrm=${TRASH_RM:-}
-
-case "$1" in
-	-e | --empty)
-		empty_trash
-		exit 0
-		;;
-	--install)
-		install_auto_empty
-		exit 0
-		;;
-	-i)
-		interactive=1
-		shift
-		;;
-	-h | --help)
-		echo "usage: trash [-e|--empty] FILE..."
-		exit 1
-		;;
-esac
-
-# main
-while test $# -gt 0; do
-	f="$1"
-	shift
-
-	[ -n "${interactive}" ] && { ask "$f" || continue; }
-
-	echo "+ $(basename "$f")"
-	if [ -n "${trashrm}" ]; then
-		[ -d "$f" ] && $rmbin -r "$f" || $rmbin "$f"
-	else
-		mv "$f" "$TRASH/"
-	fi
-done