tags:

views:

136

answers:

3

I run unsuccessfully in my .zshrc

unalias rm  
rm() { mv $* /tmp/wastebasket }

I get at the startup

/Users/Masi/.zshrc:unalias:34: no such hash table element: rm

I noticed that the hash table problem has been an unresolved bug in Ubuntu for run-help. I am not sure whether the bug applies to Mac and to rm -command too.

How can you get the notification off at the startup?

+1  A: 

That error message is because you're trying to unalias rm and there is no such alias.

Since you can alias something more than once without an error, I would change your code to be:

alias rm=x
unalias rm  
rm() { mv $* /tmp/wastebasket }

That guarantees that rm exists as an alias before you try to unalias it.

paxdiablo
+1  A: 

I'm not very familiar with zsh, but perhaps it is because rm is not an alias, but is actually a standard utility residing in /bin.

You could just alias it without attempting to unalias it first, overriding any previous alias.

vezult
+4  A: 

Everyone else is right that you simply didn't have an alias. More importantly:

DON'T do this. Some day you will be at another POSIX machine that follows POSIX standards (deleting without "recycling"), and you will casually delete something and have no way to undo it. Learn rm discipline now.

Matthew Flaschen
I agree. Learn to use rm wisely, and don't rely on any safety net you may be able to set up for yourself.
sykora
@Matt: I will follow your tip. Thank you for pointing that out!
Masi