SliTaz SliTaz Forum

You are not logged in.

#1 2011-04-18 14:08:24

iancilos
Member
Registered: 2011-04-18
Posts: 16

Setting of "Alias​​" in Cooking Slitaz 20110329 ?

Hi guys! I'm Italian so sorry for my English, but use Google Translate.

Let me explain my problem:

I just set an alias for my account to replace the command "rm" to "mv" in a folder. I simply replace "/home/tux/.Profile" the words "alias rm='rm  -i'" to "alias rm ='/bin/mv_to_folder.sh'

But damn this command is not executed when I delete a file/folder and thus is permanently deleted!

What I realize is that when I delete files/folders instead of being permanently deleted is only "moved" to a folder and then delete it by entering as Root.

You would have some idea or solution? Thank you so much for giving me your attention, little bee your advice!

Offline

#2 2011-04-18 18:58:51

Trixar_za
Administrator
Registered: 2011-03-29
Posts: 1,506

Re: Setting of "Alias​​" in Cooking Slitaz 20110329 ?

The rm command in SliTaz is provided by the BusyBox binary, so it's already a symlink, which might explain why aliases don't work that well. A better solution would be just to completely replace the rm command in /bin/rm with your own script. For example:

1. Open terminal

2. su and press enter/return key

3. Enter root passwort and press enter/return key

4. Leafpad rm

5 Create a script like this (just change where it mv to):

[c]#!/bin/sh
mv $@ /home/tux/backup[/c]
6. Save file and close leafpad.

7. Type chmod +x rm

8. Type mv rm /bin

And you'll be done. You can recreate the rm link to busybox with ln -s /bin/busybox /bin/rm if you want to get it back.

Offline

#3 2011-04-18 21:06:20

iancilos
Member
Registered: 2011-04-18
Posts: 16

Re: Setting of "Alias​​" in Cooking Slitaz 20110329 ?

Thank you so much Trixar_za for your response!

I ran your commands to the letter (easy and complete) and "rm" I can not be used as a name because it confuses the name of the command "rm"

I tried to do it manually from "Root" to create the file and make it executable by giving it all permissions read / write / execute and copy the folder "/ bin" by renaming the first file "rm" but still does not work, the files / folders continue to be deleted and not moved.

Place the file in "/ din / rm" it seems to me a link and an executable (binary?) and not as one created with lfpad (script?)

Then I located a doubt, but if I change all the "rm" command (/ bin / rm) in this way permanently lose the ability to completely delete files, even from Root, or not?

I hope this issue of Alias ​​for individual users can do, would be a great sin for a distro SliTaz cole so beautiful.

Offline

#4 2011-04-18 22:10:08

Trixar_za
Administrator
Registered: 2011-03-29
Posts: 1,506

Re: Setting of "Alias​​" in Cooking Slitaz 20110329 ?

True, but you could probably create another bash script that calls busybox rm $@ and name it whatever you want. That way the use of the rm command will result in the files being moved instead and you can use your other script to actually delete them.

Offline

#5 2011-04-18 22:13:11

iancilos
Member
Registered: 2011-04-18
Posts: 16

Re: Setting of "Alias​​" in Cooking Slitaz 20110329 ?

Explain how to do and I will!

If this fails what might be useful for many people who have this need to create aliases. It would be great!

Offline

#6 2011-04-19 10:02:46

Trixar_za
Administrator
Registered: 2011-03-29
Posts: 1,506

Re: Setting of "Alias​​" in Cooking Slitaz 20110329 ?

Ok, here is an example. I created two files. One named rm and one named del.

In del I have:

[c]#!/bin/sh
busybox rm $@[/c]
and in rm I have:

[c]#!/bin/sh
mv $@ /home/brenton/trash/$@[/c]
Now I make both run able with chmod +x del and chmod +x rm

I then go to terminal, su to root and then mv del /bin

For rm I might need more work, so I first delete the symlink rm in /bin - del -f /bin/rm and then I move rm over it with mv rm /bin

Now you'll have two new commands. rm that moves to /home/brenton/trash rather than deletes and del that actually does delete.

You will probably notice the problems with the new rm command though. It doesn't check for flags like -r which mv doesn't have. This could probably be refined a bit more, but this is just an example of how you could do it with simple bash scripts.

Offline

#7 2011-04-19 13:29:45

iancilos
Member
Registered: 2011-04-18
Posts: 16

Re: Setting of "Alias​​" in Cooking Slitaz 20110329 ?

Thanks

I run your commands to the letter and everything went well, belonging to an error which I solved by changing your line to read:

mv $@ /home/Brenton/trash/ $@ --> mv $@ /home/Brenton/trash

(otherwise gave Error and did not execute the command)

Now I have bad news and good news:

BAD. The command that you have made me change (rm) only works from a terminal window (xterm) and not PCManFM (0.5.2) as my objective, otherwise it would not make sense to have done this would have been enough to give the traditional command to move file ...

GOOD. I have tested and run Alias ​​going to change the line "alias rm = '/bin/mv_to_file'"in the file in /home/tux/.Profile "but this is only done in the terminal (Xterm) and not by PCManFM (0.5.2).

In other guides on Google explaining that you can simply change the alias in /home /user/.bashrc (in /home/user/.Profile for SliTaz).

(Italian site: http://streetcross.wordpress.com/2008/12/16/il-cestino-per-lxde-e-non-solo/)

Thanks again for your help to me! Would you have any ideas on how to change behavior "rm" of PCManFM so that you move files/folders to a folder instead of deleting them permanently?

Offline

#8 2011-04-19 14:52:41

Trixar_za
Administrator
Registered: 2011-03-29
Posts: 1,506

Re: Setting of "Alias​​" in Cooking Slitaz 20110329 ?

I've looked into it and it may be possible with something called PCManFM-Mod, which is an enhanced version of SliTaz's pcmanfm. It doesn't alter the delete command, but it does allow user defined commands, so you can add a move to trash function to that PCManfm. I'm going to try and get it to run on my SliTaz and if it works, provide a package for everybody.

Offline

#9 2011-04-19 20:40:18

iancilos
Member
Registered: 2011-04-18
Posts: 16

Re: Setting of "Alias​​" in Cooking Slitaz 20110329 ?

Yes, I knew that. In fact I tried to patch the sources PCManFM 0.5.2

Patch + Sources (I tried but I was not able to compile it with ubuntu, because the command "make" not working because he could not find any file MAKE)

https://build.opensuse.org/package/files?package=pcmanfm-legacy&project=X11%3Alxde

I do not know if this patch should be coupled the use of "trash-cli"

Or alternatively would be useful to install the package PCManFM 0.9.7 or 0.9.8 and its dependencies

Keep us informed of developments

I would love to contribute to this change of PCManFM but I have the right skills, that if only you! good fortune!

Offline

#10 2011-04-22 23:43:06

iancilos
Member
Registered: 2011-04-18
Posts: 16

Re: Setting of "Alias​​" in Cooking Slitaz 20110329 ?

Hi Trixar_za!

At what point are your test with the modified version of PAmanFM? you have good news?

Remember that we are always waiting for your miracle  ;-)

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.019 seconds, 7 queries executed - Memory usage: 1.55 MiB (Peak: 1.77 MiB) ]