Go Back   openSUSE Forums > Archives > SLS Archives > ARCHIVES - Linux Tweaks > ARCHIVES - Tips, Tricks & Tweaks
Forums FAQ Members List Search Today's Posts Mark Forums Read


ARCHIVES - Tips, Tricks & Tweaks Post your tips, tricks and tweaks about SuSE Linux in here. Please do not ask questions here - this is for factual information

 
Page 1 of 3 1 23
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 16-Aug-2007, 14:16
FeatherMonkey
Guest
 
Posts: n/a
Default

I wanted to make all the rm go to trash having accomplished it I thought I'd share may help a few new users and experienced a like. This works with KDE as the DE soz wouldn't know how to in gnome.

Edit your .bashrc to include the below next time you use the rm command it should end up in trash, rather than disappearing, good for those odd clangers.
Code:
function mod_rm()
{
kfmclient move $* trash:/
}
alias rm="mod_rm"
Also edit roots if you want to do the same with root.
  #2 (permalink)  
Old 16-Aug-2007, 14:45
geoffro
Guest
 
Posts: n/a
Default

Quote:
I wanted to make all the rm go to trash having accomplished it I thought I'd share may help a few new users and experienced a like. This works with KDE as the DE soz wouldn't know how to in gnome.

Edit your .bashrc to include the below next time you use the rm command it should end up in trash, rather than disappearing, good for those odd clangers.
Code:
function mod_rm()
{
kfmclient move $* trash:/
}
alias rm="mod_rm"
Also edit roots if you want to do the same with root.
[/b]
Thanks Stef great tip

/Geoff
  #3 (permalink)  
Old 16-Aug-2007, 14:58
FeatherMonkey
Guest
 
Posts: n/a
Default

No problem Geoff though I've noticed a slight problem just need to work away around it at the moment it won't do recursion close

Now to sort this bit out seems I posted to soon in excitement.

I'm a doughnut it works fine at removing directories just was trying to pass -r to it.
  #4 (permalink)  
Old 16-Aug-2007, 16:57
microchip
Guest
 
Posts: n/a
Default

you should be careful if you work a lot with scripts on the command line since most of these scripts are not written to escape aliases which are put in .bashrc. So if a script does some operation on a file and after that it deletes this file, the file won't be deleted but it'll end up in your trash bin, but still you'll get the false impression that it's deleted... if you run scripts frequently which operate on large files and after that delete them, you can easily fill up your file system because these files won't be deleted but will stay in your trash bin. It is better to choose a different alias name and not "rm" to not confuse scripts which are not written to escape things in .bashrc

maybe alias "trash" is better?
  #5 (permalink)  
Old 16-Aug-2007, 17:17
FeatherMonkey
Guest
 
Posts: n/a
Default

Valid point and something to take into consideration but my concern was to replace the default rm command. Not have an alternative.

I've not seen anything going into trash yet so it seems I may be OK with my usage. But I guess others wil have to judge for themselves.
  #6 (permalink)  
Old 16-Aug-2007, 17:31
microchip
Guest
 
Posts: n/a
Default

why would you want to replace "rm" ? rm is there to delete files, not move them to some other place. I think it is much more logical to have the normal "rm" operate like it does and to have a "trash" alias if you are not sure about the deletion of a file so you use "trash" to move it to the trash bin

On some systems (Fedora comes to mind), if you only use "rm somefile" then "rm" will ask you for confirmation before deleting it so you'll have to use "rm -f somefile" to skip this confirmation. So to automatically avoid this confirmation step, people put in .bashrc a alias like

alias rm="rm -f $*"

Not so in SUSE, as when you issue "rm somefile" the "rm" version of SUSE is modified to not ask confirmation before deletion
  #7 (permalink)  
Old 16-Aug-2007, 17:39
FeatherMonkey
Guest
 
Posts: n/a
Default

I like, you like each to there own
  #8 (permalink)  
Old 16-Aug-2007, 17:41
microchip
Guest
 
Posts: n/a
Default

I guess bad practices will never end
  #9 (permalink)  
Old 16-Aug-2007, 17:45
FeatherMonkey
Guest
 
Posts: n/a
Default

Proabably not but I want rm to remove to trash when its invoked from the cli if you have a solution then I'm ears,

I'm not interested in alternatives I don't like the default disappear, I don't want to confirm. I can't remove rm from the users path easily.

I want the opportunity of undoing a rm from th cli so if you have good practices then I'm listening.
  #10 (permalink)  
Old 16-Aug-2007, 17:53
microchip
Guest
 
Posts: n/a
Default

that's why we have "mv" but you use whatever you want
 
Page 1 of 3 1 23

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2