Re:Some Useful Bash Aliases – Chuck Carroll
by metal on Monday December 25, 2023 @02:31PM
(#38765386)
Do this in important directories for added safety:
$ touch -- - i
This creates a file called "-i" which will add the interactive flag, prompting you before deleting every file that rm was going to delete.
Re:Some Useful Bash Aliases – Chuck Carroll
by Galanwe on Monday December 25, 2023 @04:15PM
(#38766189)
That seems flaky at best. Basically you rely on "*" expansion to inject the -i.
While that may work for `rm -rf *`, it won't for `rm -rf foo/*`, `rm -rf foo`, etc
Re:Some Useful Bash Aliases – Chuck Carroll
by metal on Monday December 25, 2023 @05:50PM
(#38767041)
That's the point. You're not relying on it, it's a safety to save yourself from an unintended glob expansion.
Re:Some Useful Bash Aliases – Chuck Carroll
by Groxx on Monday December 25, 2023 @05:40PM
(#38766947)
Or for far better reliability, just use safety and add that to the config.
Re:Some Useful Bash Aliases – Chuck Carroll
by deafpolygon on Monday December 25, 2023 @02:00PM
(#38765094)
Agreed. I like that you need to use '-r' ... it's that extra layer of safety and intention. A whole directory gone is a bit hard to recover from.
Re:Some Useful Bash Aliases – Chuck Carroll
by cassepipe on Monday December 25, 2023 @06:59PM
(#38767530)
A way better solution is to alias trash-d as a drop-in replacement for `rm` :
https://github.com/rushsteve1/trash-d
Re:Some Useful Bash Aliases – Chuck Carroll
by ttyprintk on Monday December 25, 2023 @10:50PM
(#38768762)
Also, ‘gio trash’ is widespread.
Re:Some Useful Bash Aliases – Chuck Carroll
by cassepipe on Tuesday December 26, 2023 @07:22AM
(#38771174)
Never heard of it before, let's man gio :
gio is a utility that makes many of the GIO features available
Ok, thanks I guess :D
Re:Some Useful Bash Aliases – Chuck Carroll
by ttyprintk on Tuesday December 26, 2023 @06:17PM
(#38777134)
What I mean is: a precept of command-line fluency is to be able to drop onto arbitrary systems and change them in ways predictable to the next sysadmin. ‘gio’ is a vague entry point to a library, and even if the next sysadmin doesn’t know about gnome, the files you trashed end up in a common recycling bin.
On the other hand, KDE has a syntax that deserves an alias.
Re:Some Useful Bash Aliases – Chuck Carroll
by mturmon on Monday December 25, 2023 @08:37PM
(#38768144)
Agree. (I actually feel the same way about aliasing rm to “rm -i“).
I depend on the out of box behavior of rm. I’ll run “rm *” in a directory that has subdirectories I want to preserve, but where I want to erase the files.
This is insanely dangerous. Don't do this.