The origins of my idea… (aka TL;DR;)
I am a big fan of Arch Linux. While many think Arch is so stripped down that it’s not suitable for server environments or too “hands on” for noobs, I personally think the power of Arch resides in its very simplicity. Arch is a rolling release distro, which means it doesn’t have release numbers (like, for example, Ubuntu) but rather relies on frequent updates to the different packages keeping them up to date, compatible and as close to their upstream versions as possible. It doesn’t come with a GUI by default (hell, it doesn’t come with almost anything by default, I don’t even think it’s got wget prepackaged…) but you can find pretty much any program worth a damn via its package manager (pacman) and whatever you can’t find there can be found on AUR (Arch User Repository) 99% of the time.
Arch Linux is also a great distro for those who want to learn Linux the hard right way. Most of the time it forces you to configure, troubleshoot, install or manage your packages via CLI and without training wheels while, at the same time, providing an invaluable source of knowledge and guidance through its extensive documentation and lively community. As a matter of fact that’s how I found out about it… If you google some Linux command, or way to configure an application on Linux chances are you are going to end up on an Arch Wiki article.
Yep I’ll get to the point…
Now, since I embraced the Arch Way, I use command line for all my Linux tasks however I noticed that due to my ADHD I tend to impulsively obliterate files to recover precious space or just to keep things clean… This leads to regret. Regret leads to anger which leads to the Dark Side… So I figured that as a Bash Padawan I should have done something about it and I did. I looked up some form of CLI recycle bin and found out that many distros that make use of graphical interfaces have a recycle bin embedded in their file managers and Ubuntu even provides a command line version of it. Doing a quick search on AUR showed a couple of options that emulated what I wanted but none of them seemed polished or even maintained enough for my taste. So based on the principles that “if you want something done right(ish), do it yourself” and that “sharing is caring” I decided to make my own trash command and post it on AUR (and GitHub).
The command is pretty simple and, while not perfect, it accomplishes what I wanted:
$trash [file1] [file2]...
Moves the given file/s or directory to the trash folder (/tmp/trash/)
$trash -l
Shows the content of the trash folder
$trash -r file1 [-r file2 -r file3 ...]
Restores file/s or folder/s to their previous locations with their original attributes
$trash -R
Restores ALL file/s or folder/s to their previous locations with their original attributes
$trash -e
Empties the trash bin
$trash -p file1 [-p file2 -p file3 ...]
Purge (delete permanently!) file/s or folder/s from the trash can.
$trash -v
Verbose. Add some additional information about the performed operation.
$trash -V
Show current version.
$trash -h
Show usage.
For more info on how to install it you can check the Readme file on GitHub and I hope you’ll find it useful as much as I do!
