Slackermedia

The Workflow Edition

What is Trashy?

UNIX is a powerful system; when you tell it to do something, it does it. That's why people use GNU Linux and BSD and Solaris systems; they like being in control of their computer.

On the other hand, when a computer blindly does what you tell it to do, you'd better be sure you want to do it. Especially when you issue the dangerous rm command, which tells your computer to remove a file.

On the command line, there is no trashcan. If you tell a computer to remove a file, it removes the file, no questions asked. Sound like a bad idea? Sometimes it is! Happily, there is trashy, the sane and portable trashy intermediary.

What Does Trashy Do?

Trashy provides you with a trash command, which does two things:

  1. Moves "deleted" files to your system trash instead of actually deleting them

  2. Empties that trash when you tell it to.

Simple as.

How Do I Install?

  1. Currently you can grab trashy from its git repository by issuing this command:

    git clone https://gitlab.com/trashy/trashy.git

  2. Now all you need to do is install it.

    cd ./trashy && su -c ./install.sh

  3. Unless you're quite new to Unix, you probably have fingers trained to type rm when you really mean trash. To solve this, you can make an alias so that when you accidentally type rm, the file is trashed instead of deleted forever.

    echo "alias rm='/usr/local/bin/trash'" >> ~/.bashrc && source ~/.bashrc

    Note that this is a personal alias and will not interfere with the root user's usage of rm, but if you are still hesitant to interfere with such a low-level, common command, then at least alias rm to 'rm -i'

And that's all there is too it! No more accidental, irreversible deletion of files!

Note: Since sometimes you will probably really want to delete a file, you can always access the actual rm command by typing in the full path: /bin/rm (but use it sparingly; remember the reason you installed trashy in the first place was to avoid dangerous rm mishaps!)

How do I uninstall?

If you mean you want your unadulterated rm command back, you can do that by removing the alias:

sed -i 's_alias rm_#alias rm_' ~/.bashrc

But if you want to remove trashy entirely from your system then simply remove it, as it is a self-contained script:

su -c '/bin/rm /usr/local/bin/{trash}'

Can I Integrate trashy With KDE or XFCE?

By default, trashy uses the ~/.local/share/Trash directory. This means that if you are using the KDE or XFCE desktop, or any desktop that follows the Free Desktop spec, the file will automagically appear in your desktop trash can. You can even restore the files by right-clicking on the icon and selecting restore, because trashy follows the Free Desktop spec as closely as it can. (A future feature planned for trashy is the ability for it to restore files in the Free Desktop restore manner, but for now you would have to do that manually from the command line, or through the GUI.)

If you want to integrate it with some other trash can that does not follow the Free Desktop specification, you may be able to do that simply by changing the path of the trash can in the trash script.

I Love This But I Want More

Features requests, patches, and bug reports are always welcome. You can contact the author via the email addresses provided in the front matter of the Slackermedia book, or at the end of each GNU World Order episode.

I'm a Real Geek and I love rm.

If you love rm, continue using rm. I personally love rm; it's a very effective tool for instantly and permanently erasing a file from the face of this Earth and all possible worlds and timelines. For those who just want a little time apart from their files before eradicating them completely, there's trashy.

100% Free & Open Source Software