DSL Ideas and Suggestions :: "Add to filetool.lst" button



I find this "very handy" , and I miss not having it in emelfm.
With the F keys being so similar to NC, MC, and others,
I used to hit the F6 key to rename/move , but in emelfm, it only moves..

So, I programmed the F9 key to rename files..

Open emelfm
Click on the "configure" button in the center row
Highlight the title "buttons" in the left-hand row
In the center portion, click "add"
In the new window- type 'Rename' as a label
Click the 'system' option, and select RENAME
Click OK to save..

Remember to add the .emelfm dir to your filetool.lst to save between backups!

Another annoying thing is when your in a long list of files,
looking to get to the top of the list ( .. ) , and you hit the 'home' key,
and find yourself back in /home/dsl , rather than at the top of the dir
you 'were' in ..    grrr...

I'd like to reprogram that as well..

73
ke4nt

Rogue Streak:

Configure/Buttons/Add...
command:
[removed -- see below]

I'm not sure if the preceding slash is a problem.  if so you might need to change the command a bit.

EDIT:
That didn't work with multiple files, but this one will.  It also removes the leading slash.
Code Sample
for i in %f; do grep `pwd|cut -c 2-`/$i /home/dsl/filetool.lst || echo `pwd|cut -c 2-`/$i >>/home/dsl/filetool.lst; done



EDIT2:
In case you are interested in learning some script (and since i'm just twiddling my thumbs on a sunday afternoon), i'll try to break this down for you....

It uses a "for" loop, which basically does everything within the loop, applied to whatever immediately follows "for".  In this case it is $i, which is a variable that contains the selected file(s).  EmelFM uses %f to specify the files selected.  If there are multiple files selected, %f would be a list of all those files.  So $i represents the list of files, one at a time.
Example:  foo, bar, and foobar are selected, so %f would be "foo bar foobar".
"for i in %f" would be the same as "for i in foo bar foobar", which says "do the upcoming actions for foo, then bar, then foobar".

`pwd|cut -c 2-`/$i
pwd returns the current directory, which is piped to cut.  Cut returns everything from the second character on to the end of the line, and /$i appends a slash and the selected file.  The backticks say "do everything in the backticks as a command, and the result is what we work with".  So if "foo" is the currently selected file, and the current directory is /usr/bin, then it would do this:
1) pwd = /usr/bin
2) cut -c 2- = usr/bin
3) /$i = /foo
4) result: usr/bin/foo

Grep looks for the result (usr/bin/foo) in /home/dsl/filetool.lst

the "||" means "or".  If the grep succeeds, the following command is not run.  If the grep fails, then "echo usr/bin/foo >>/home/dsl/filetool.lst" is run.  This appends usr/bin/foo to filetool.lst

Very nicely explained, mikshaw! :D
I have some programming experience, but mainly in Flash Actionscript.  Should this code be all one line, or can it be formatted in a structured manner, eg.
Code Sample
for i in %f;
 do grep `pwd|cut -c 2-`/$i /home/dsl/filetool.lst
||
 echo `pwd|cut -c 2-`/$i >>/home/dsl/filetool.lst;
done
?
I see how it's operating once I understood the basic if/else structure.
So "pwd" would be "present working directory"?
"cut -c 2-" - is that "cut everything from the 2nd character on, and pass it on", or "cut up to the second character"?
"echo something >> some.file" adds the results to the specified file?

RE: foo & bar, just tried to track down it's origins and original meaning, seems nothing is clear cut:
Etymology of "Foo"
Looks like there could be at least 5 possible origins.  Interesting note is that "fubar" could possibly have come from the German "furchtbar", which is (apparently, I don't speak German, though kinda trying to learn a bit) "terrible"...

And now back to our regular broadcast.

I also have had a decent amount of actionscript experience, which made learning bash much easier than it might have been.

Your multiline format is close.  Typically it's like this:
for blah in something something; do
command1
command2
command3
done

If you use && or || to chain commands, the commands should be on the same line.  You can escape the newline character with a backslash if you want to keep things compact:
for i in %f; do
grep `pwd|cut -c 2-`/$i /home/dsl/filetool.lst || \
echo `pwd|cut -c 2-`/$i >>/home/dsl/filetool.lst;
done
Using the escape, you can break up the lines wherever you think they would be most readable.  Just make sure the character immediately following the backslash is really a newline and not a space. Also, in a multiline script you can save yourself some typing, and possible retyping if you want to make a future change, by replacing redundant parts with variables:
list=/home/dsl/filetool.lst
file="`pwd|cut -c 2=`/$i"
for i in %f; do
grep $file $list || echo $file >> $list ;
done

EmelFM probably won't read a multiline command from its config files, so that's why i put it all on one line.  In a script I try to keep most lines within 70-80 characters just so it's easy to read in a small terminal.

pwd is what you said

"echo something >> somefile" adds(appends) "something" to somefile
"echo something > somefile" replaces somefile with a new somefile containing only "something"

the cut command starts at the second character and prints everything from that point to the end of the line.  If the command were "cut -c 2" instead of "cut -c 2-" (note the hyphen after the 2) it would print the second character only.  "-c -2" would print the first and second characters, and "-c 2-6" prints from the second to sixth characters inclusive.  The "-c" option specifies counting per character, as opposed to byte(-b) or field(-f).

Mikshaw, if you aren't a lecturer/tutor/teacher, you should be!  I'll be a referee for you if you want to apply for said positions! :p
Next Page...
original here.