Last active
September 1, 2023 10:11
-
-
Save knollet/809c0611ee854810d2839c8d0681c778 to your computer and use it in GitHub Desktop.
source my-trash-cli.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function trash { | |
TRASHDIR="$HOME/TRASH" | |
DATE="$(date '+%Y-%m-%d_%H:%M:%S.%N')" | |
if [ -z "$1" ]; then | |
echo "usage: $0 <filenames...>" > /dev/stderr | |
exit 1 | |
fi | |
for FILE in "$@"; do | |
DEST="$TRASHDIR/$DATE/$(dirname "$FILE")" | |
mkdir -p "$DEST" | |
mv "$FILE" "$DEST" | |
done | |
} | |
function trash-ls { | |
TRASHDIR="$HOME/TRASH" | |
ls "$TRASHDIR"/* | |
} | |
function trash-empty { | |
TRASHDIR="$HOME/TRASH" | |
echo "really clear trash?" | |
select yn in "Yes" "No"; do | |
case $yn in | |
Yes ) | |
chmod -R +w "$TRASHDIR" | |
rm -rf --one-file-system "$TRASHDIR"/*; | |
break;; | |
No ) exit;; | |
esac | |
done | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment