trs(1)
| TRS(1) | User Commands | TRS(1) |
NAME
trs - safely move files to trash using the XDG Trash specification
SYNOPSIS
trs [OPTIONS] FILE...
trs COMMAND [OPTIONS]
DESCRIPTION
trs (from TRaSh) is a secure CLI utility for moving files to trash instead of permanently deleting them. It follows the XDG Trash specification, making it compatible with desktop environments like GNOME and KDE.
Files are moved to:
- •
- $XDG_DATA_HOME/Trash or ~/.local/share/Trash/ (home trash)
- •
- $VOLUME/.Trash-$UID/ (volume trash for cross-device files)
COMMANDS
- trs [FILE...]
- Move files or directories to trash.
- trs list
- List all files in trash with their index, name, size, and deletion date.
- trs restore [NAME|INDEX]
- Restore files from trash. Without arguments, shows interactive selection with fuzzy search. Use --last to restore the most recently trashed file.
- trs empty [OPTIONS]
- Empty the trash. Use --days N to only remove files older than N days.
- trs status
- Show trash statistics (file count, size, locations).
- trs version
- Print version information.
OPTIONS
Global Options
- -f, --force
- Ignore nonexistent files (when trashing).
- -r, --recursive
- Remove directories and their contents recursively.
- -v, --verbose
- Verbose output.
- --json
- Machine-readable JSON output.
- -h, --help
- Show help message.
Restore Options
- --last
- Restore the most recently trashed file.
- -f, --force
- Overwrite existing files when restoring.
Empty Options
- --days N
- Only remove files older than N days.
Status Options
- -v, --verbose
- Show detailed statistics (oldest/newest dates, largest files).
EXIT CODES
- 0
- Success
- 1
- Error
- 2
- Invalid usage
ENVIRONMENT
- XDG_DATA_HOME
- Custom data directory (default: ~/.local/share).
- NO_COLOR
- If set, disable colored output.
FILES
- ~/.local/share/Trash/files/
- Directory containing trashed files.
- ~/.local/share/Trash/info/
- Directory containing .trashinfo metadata files.
- $VOLUME/.Trash-$UID/
- Volume-specific trash directories for files on other filesystems.
SECURITY
trs implements multiple security measures:
- •
- Symlink protection — never follows symlinks when copying or removing
- •
- Path validation — prevents path traversal attacks
- •
- System path protection — refuses to restore to critical system directories
- •
- TrashInfo validation — validates paths from .trashinfo files
- •
- DoS prevention — size and iteration limits on all operations
EXAMPLES
- trs file.txt
- Move a file to trash.
- trs -r directory/
- Move a directory to trash (recursive).
- trs -f nonexistent
- Force mode — ignore nonexistent files.
- trs list --json
- List all trashed files in JSON format.
- trs restore
- Launch interactive TUI with fuzzy search.
- trs restore --last
- Restore the most recently trashed file.
- trs restore config.json
- Restore a file by name.
- trs restore 1
- Restore a file by index (from trs list).
- trs empty --days 7
- Remove files older than 7 days.
- trs status -v
- Show detailed trash statistics.
SEE ALSO
AUTHOR
Written by amakeenk.
LICENSE
MIT License.
| March 2026 | trs 0.4.0 |
