trash-cli
Move files and directories to the trash
TLDR
View documentation for the original command
SYNOPSIS
trash-put [options] file...
trash-list [options]
trash-restore [options] [index]
trash-empty [options] [days]
trash-rm [options] file...
PARAMETERS
-v, --verbose
Displays detailed information about the operation. This option applies to trash-put, trash-list, trash-restore, trash-empty, and trash-rm.
--help
Shows a help message and exits. This option is available for all trash-cli commands.
--version
Shows the program's version number and exits. This option is available for all trash-cli commands.
-f, --force
Does not ask for confirmation before performing the operation. This option is primarily used with trash-empty to empty the trash without a prompt and with trash-rm to remove files from the trash without confirmation.
-d DAYS, --days DAYS
Used with trash-empty, this option specifies that only files older than the given number of DAYS should be permanently deleted from the trash.
index
Used with trash-restore, this argument specifies the numerical index of the file to restore from the trash list. If omitted, trash-restore will provide an interactive list for selection.
file...
Used with trash-put, this argument specifies one or more files or directories to move to the trash. When used with trash-rm, it specifies files to permanently remove from the trash by name.
DESCRIPTION
trash-cli provides a set of command-line tools that move files to the desktop trash folder, rather than permanently deleting them like the rm command. This offers a safety net, allowing users to restore accidentally deleted files. It adheres to the XDG Trash specification, ensuring compatibility with graphical desktop environments like GNOME, KDE, and XFCE.
The suite includes several commands:
trash-put: Moves files to the trash.
trash-list: Lists all files currently in the trash.
trash-restore: Restores files from the trash interactively or by index.
trash-empty: Permanently deletes all or old files from the trash.
trash-rm: Permanently deletes specific files from the trash by name.
This makes trash-cli an essential tool for users who prefer the command line but desire the security and convenience of a graphical trash can.
CAVEATS
Cross-Filesystem Issues: Trashing files across different filesystems can sometimes lead to complications with restoration or trash management if the trash directory structure isn't consistently accessible or managed per filesystem.
Not a True Undo: While trash-cli provides a valuable safety net, it's not an infallible undo mechanism. The trash can still be manually emptied, files might be too large to be trashed, or the trash partition could fill up or be deleted.
User-Specific Trash: The trash is typically user-specific. Files trashed by one user are not visible in or restorable from another user's trash directory.
XDG BASE DIRECTORY SPECIFICATION ADHERENCE
trash-cli adheres to the XDG Base Directory Specification for trash management. This means trashed files are typically stored in a location like $XDG_DATA_HOME/Trash (which usually defaults to ~/.local/share/Trash for individual users). For files on other filesystems, a .Trash-UID directory is created at the top level of that filesystem. This adherence ensures seamless integration and compatibility with graphical desktop environments that also follow this standard, allowing items trashed from the command line to appear in the desktop trash and vice-versa.
HISTORY
trash-cli was developed as a safer, XDG-compliant alternative to the destructive rm command. It addresses the common user need for a 'trash bin' functionality in the command-line environment, mirroring the behavior of graphical desktop environments. Its development has focused on adhering to the XDG Trash specification to ensure interoperability and a consistent user experience across Linux desktops.