2021-10-30 09:49:23 +02:00
|
|
|
# trash.sh - A cli trash bin for files and directories instead of deleting them directly
|
2021-09-21 17:13:17 +02:00
|
|
|
|
2021-10-28 02:02:15 +02:00
|
|
|
[![Build Status](https://drone.pyas.de/api/badges/Kim/trash.sh/status.svg)](https://drone.pyas.de/Kim/trash.sh)
|
2021-09-21 18:09:39 +02:00
|
|
|
|
2021-09-21 17:30:49 +02:00
|
|
|
## Installation:
|
2021-10-28 02:11:47 +02:00
|
|
|
Put the trash.sh file to your desired location (e.g home directory) and source it in your `$HOME/.bashrc` or in `/etc/.bashrc`:
|
2021-09-21 17:30:49 +02:00
|
|
|
|
2021-09-21 18:26:46 +02:00
|
|
|
. /path/to/trash.sh
|
2021-09-21 17:30:49 +02:00
|
|
|
|
2021-10-28 02:02:15 +02:00
|
|
|
- When the script runs, it first checks if `$HOME/.trash/` (your trash bin) exists and creates it if missing.
|
2021-09-21 20:53:50 +02:00
|
|
|
|
2021-10-28 02:02:15 +02:00
|
|
|
Add the cleanup job to your crontab:
|
2021-09-21 17:30:49 +02:00
|
|
|
|
|
|
|
# .trash cleanup of all contents (files and dirs) older than 31 days every morning at 06:00
|
2021-10-28 02:02:15 +02:00
|
|
|
0 6 * * 0 find $HOME/.trash/ -mtime +31 -delete
|
2021-09-21 17:30:49 +02:00
|
|
|
|
|
|
|
## Usage:
|
|
|
|
|
2021-09-21 18:26:46 +02:00
|
|
|
- `trash FILE1 DIR2 ...` or `trash_put FILE1 DIR2 ...` to move files and directories with relative or absolute paths to your .trash
|
|
|
|
- `trash_list` to list all files and dirs that you put in the trash in the last 30 days
|
|
|
|
- `trash_empty` to remove all files and dirs in your trash
|
|
|
|
- `trash_rm FILE1 DIR2 ...` to delete specific files and directories in your trash
|
|
|
|
- `trash_restore FILE1 DIR2 ...` to restore specific files and directories from your trash to it's origin
|
2021-09-21 22:04:18 +02:00
|
|
|
|
|
|
|
## Credits
|
2021-10-28 02:02:15 +02:00
|
|
|
Repo Icon made by [Freepik](https://www.freepik.com "Freepik") from [www.flaticon.com](https://www.flaticon.com/ "Flaticon")
|