trash-cli
Use trash-cli to safely delete files by moving them to the system trash instead of permanently removing them. This prevents accidental data loss and allows file recovery. Use instead of rm when you want recoverable deletion.
- License 许可
- MIT
- 最近更新
- 2026-06-07
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- trash-cli
- version
- 1.0.5
- metadata
- { "openclaw": { "emoji": "🗑️", "install": [ { "id": "brew", "bins": [ "trash-put", "trash-list", "trash-restore", "trash-empty", "trash-rm" ], "kind": "brew", "label": "Install trash-cli (brew)", "formula": "trash-cli" }, { "id": "pip", "kind": "pip", "label": "Install trash-cli (pip)", "package": "trash-cli" } ], "requires": { "bins": [ "trash-put", "trash-list", "trash-restore", "trash-empty", "trash-rm" ] } } }
- description
- Use trash-cli to safely delete files by moving them to the system trash instead of permanently removing them. This prevents accidental data loss and allows file recovery. Use instead of rm when you want recoverable deletion.
03 SKILL.md 正文
trash-cli
A command line interface to the freedesktop.org trashcan. It trashes files recording the original path, deletion date, and permissions. It uses the same trashcan used by KDE, GNOME, and XFCE.
Installation
# Via Homebrew (Linux/macOS)
brew install trash-cli
# Via pip
pip install trash-cli
# Via apt (Debian/Ubuntu)
sudo apt install trash-cli
# Via pacman (Arch Linux)
sudo pacman -S trash-cli
# Via dnf (Fedora)
sudo dnf install trash-cli
Commands Overview
| Command | Description |
|---|---|
trash-put |
Move files/directories to trash |
trash-list |
List trashed files |
trash-restore |
Restore trashed files |
trash-empty |
Permanently delete trashed files |
trash-rm |
Remove specific files from trash |
trash-put
Move files or directories to the trash can.
trash-put <file> # Trash a file
trash-put <dir>/ # Trash a directory
trash-put -f <file> # Silently ignore nonexistent files
trash-put -v <file> # Verbose output
Options
-f, --force- Silently ignore nonexistent files-v, --verbose- Explain what is being done--trash-dir TRASHDIR- Use TRASHDIR as trash folder
Notes
- Unlike
rm,trash-putdoes not require-Rfor directories - Files trashed from home partition go to
~/.local/share/Trash/ - Files from other partitions go to
$partition/.Trash/$uidor$partition/.Trash-$uid
trash-list
List all trashed files.
trash-list # List all trashed files
trash-list | grep <pattern> # Search for specific files
trash-list --all-users # List trashcans of all users
Output Format
2008-06-01 10:30:48 /home/user/bar
2008-06-02 21:50:41 /home/user/baz
Format: deletion_date original_path
trash-restore
Restore trashed files to their original location.
trash-restore # Interactive restore
trash-restore --overwrite # Overwrite existing files
trash-restore --sort date # Sort by date (default)
trash-restore --sort path # Sort by path
Interactive Mode
$ trash-restore
0 2007-08-30 12:36:00 /home/andrea/foo
1 2007-08-30 12:39:41 /home/andrea/bar
2 2007-08-30 12:39:41 /home/andrea/baz
What file to restore [0..2]: 0
- Enter the number to restore that file
- Use
0-2,3to restore multiple files - Use
--overwriteto replace existing files
trash-empty
Permanently remove files from trash.
trash-empty # Remove ALL trashed files
trash-empty 7 # Remove files older than 7 days
trash-empty 1 # Remove files older than 1 day
Examples
# Delete everything in trash
trash-empty
# Keep only files from the last 7 days
trash-empty 7
# Keep only today's files
trash-empty 1
trash-rm
Remove specific files from trash (by pattern).
trash-rm <pattern> # Remove files matching pattern
trash-rm '*.o' # Remove all .o files
trash-rm foo # Remove all files named "foo"
trash-rm /full/path # Remove by original path
Note: Use quotes to protect pattern from shell expansion.
trash-rm '*.log' # Correct
trash-rm *.log # Wrong - shell will expand
Safety Tips
Replace rm with trash-put
Add to .bashrc or .zshrc:
# Remind yourself not to use rm directly
alias rm='echo "Use trash-put instead!"; false'
# Or use a safer alias
alias rm='trash-put'
To bypass the alias when you really need rm:
\rm file.txt
Recovery Workflow
- Check what's in trash:
trash-list - Find your file:
trash-list | grep <filename> - Restore:
trash-restore
Trash Location
- Home partition:
~/.local/share/Trash/ - Other partitions:
$mount_point/.Trash/$uidor$mount_point/.Trash-$uid
Limitations
- Does not support BRTFS volumes
- Cannot trash files from read-only filesystems
FAQ
Creating a top-level .Trash directory
If you need to create a trash directory on a different partition:
sudo mkdir --parent /.Trash
sudo chmod a+rw /.Trash
sudo chmod +t /.Trash
Should I alias rm to trash-put?
The author advises against this. Although trash-put seems compatible with rm, it has different semantics that will cause problems. For example, while rm requires -R for deleting directories, trash-put does not.
Instead, use a warning alias:
alias rm='echo "This is not the command you are looking for."; false'
To bypass when you really need rm:
\rm file.txt
See Also
04 同仓库更多 Skills
crowd-prompting
A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.
ceaser
Interact with the Ceaser privacy protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- shield, unshield, note management, and protocol queries. All ceaser tool calls use CLI subcommands (npx -y ceaser-mcp <subcommand>). Ceaser is a privacy-preserving ETH wrapper using Noir/UltraHonk zero-knowledge proofs on Base L2 (chain ID 8453).
ceaser-send
Fully automated private ETH transfer via Ceaser Protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- all ceaser tool calls use CLI subcommands (npx -y ceaser-mcp <subcommand>). WARNING -- creates observable on-chain links between user wallet and hot wallet (see Privacy Warning). Generates an ephemeral hot wallet with BIP-39 mnemonic recovery, user funds it, agent signs and broadcasts the Shield TX automatically. Exactly one manual step required (funding the hot wallet with ETH). Uses Noir/UltraHonk zero-knowledge proofs.
dilemm-ai
Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).
moldium
Post and manage content on the Moldium blog platform. Triggered by "post to Moldium", "write a blog post", "publish an article", etc.
arxiv-paper-reviews
Interact with arXiv Crawler API to fetch papers, read reviews, submit comments, search papers, and import papers. Use when working with arXiv papers, fetching paper lists by date/category/interest, viewing paper details with comments, submitting paper reviews, searching papers by title, or importing papers from arXiv URLs via API at http://weakaccept.top:8000/.