Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.

2009/01/23

Considering del ...

Here is a shell-script replacement for rm. As you know, rm just kills a file or directory outright. Often this is what we want. But every windowing system I know uses an intermediate Trash Can, a place to store your deleted files in case you say "No, I really wanted that directory full of L0Lcats".

So, the question is, how do I get that functionality in your command line? They call it del, but I prefer trash, as del on Windows doesn't put it in the Trash Can, it blows it away.

Anyway, the code:

# !/bin/bash
# http://ubuntuforums.org/showthread.php?t=124137&highlight=trash
mv -vi -- "$@" $HOME/.Trash


Problems. When I tried this, the file was moved to .Trash, because there was no .Trash dir. Why was there no .Trash dir? Because with Ubuntu Intrepid (and I have no idea when things changed), the Trash dir is $HOME/.local/share/Trash/. Specifically, there's $HOME/.local/share/Trash/files/, which holds the actual files and directories, and $HOME/.local/share/Trash/info/.

Let me show you a sample *.trashinfo file.

[Trash Info]
Path=/home/jacoby/Desktop/SyntaxHighlighter_1.5.1.rar
DeletionDate=2009-01-23T10:07:19


For each file and directory in the files directory, there's a .trashinfo file saying when it was deleted and where it restores to. So, obviously, the del/trash script is not up to the task of today's Gnome trashing. But what to do about it? More later, as I consider the problem set.