Introducing trash-u (File::Trash::Undoable)
To trash your files:
% trash-u foo.tmp *.bak
To see the contents of your trash:
% trash-u --list-contents
To empty your trash:
% trash-u --empty
Unlike trash-cli (and like rmv), trash-u supports undo (called rollback in rmv). And unlike rmv, trash-u supports redo. Multiple undo/redo is supported. It's also worth noting that rmv currently does not support per-filesystem trash (everything goes to $HOME, which might cause heavy copying between devices).
To undo your last action:
% trash-u --undo
And to redo:
% trash-u --redo
To see your actions history:
% trash-u --history
To discard history (forget undo/redo information):
% trash-u --clear-history
trash-u also supports dry-run mode to show what's going to be deleted:
% trash-u foo.tmp *.bak --dry-run --verbose
- New module, not much tested yet, be careful with your files.
- The trash-u utility is originally written to demonstrate the Rinci undo and transaction protocol. The utility requires SQLite to store transaction information. There's another simpler demonstration script symlink-u to setup/unsetup symlinks, distributed along with Perinci::CmdLine.
- File::Trash::FreeDesktop, which provides the actual trashing routines, was written from scratch and reading the freedesktop.org spec to first CPAN release in about 3.5 hours.
- Writing File::Trash::Undoable and trash-u utility from scratch to first CPAN release requires just around 2 hours of coding time. This is because the undo and command-line framework already do the hard work (providing --undo, --redo, --history, --clear-history, --dry-run, and --help).
- Tweaking and polishing further will take extra time, though.