View Single Post
Old 13 October 2021, 22:43   #8
malko
Ex nihilo nihil
 
malko's Avatar
 
Join Date: Oct 2017
Location: CH
Posts: 4,935
Today I changed a bit the script in order to allow the display to be on 2, 3 or 4 columns. This is done through the COLS argument. Default is now 4 columns.
I also have reorganised the script to try to make it bit faster. I gained 2 seconds as now it only takes a max of 7 seconds to display the result. Not bad considering how it works .
Furthermore the temporary files are now identified to the shell meaning that it is possible to launch simultaneous ls commands from different Shells.

Here is the code of the v1.1 :

Code:
ls (v1.1) :
.key DIR,COLS/K
.bra {
.ket }
.def DIR ""
.def COLS 4
run >NIL: list >t:lsf.{$$} "{DIR}" files lformat="*e[31m%s*e[0m*e[1E*e[1A*e[mlk" +
echo >t:lsefs{$$} "0(f/.info/;d )*Nw" +
edit >NIL: FROM t:lsf.{$$} TO t:lsf{$$} WITH t:lsefs{$$}
run >NIL: list >t:lsd{$$} "{DIR}" dirs lformat="*e[33m%s*e[0m*e[1E*e[1A*e[mlk"
list >t:lsi{$$} "{DIR}" files pat=#?.info lformat="*e[32m%s*e[0m*e[1E*e[1A*e[mlk"
if VAL {COLS} EQ 2
   skip 2cols
endif
if VAL {COLS} EQ 3
   skip 3cols
endif
lab 4cols
run >NIL: echo >t:lsees{$$} "0(f/[mlk/;e/[mlk/[19C/;f/[mlk/;e/[mlk/[38C/;f/[mlk/;e/[mlk/[57C/;f/[mlk/;e/[mlk/N/)*Nw"
echo >t:lsejl{$$} "0(3CL//;n)*Nw"
skip mlk
lab 3cols
run >NIL: echo >t:lsees{$$} "0(f/[mlk/;e/[mlk/[26C/;f/[mlk/;e/[mlk/[52C/;f/[mlk/;e/[mlk/N/)*Nw"
echo >t:lsejl{$$} "0(2CL//;n)*Nw"
skip mlk
lab 2cols
run >NIL: echo >t:lsees{$$} "0(f/[mlk/;e/[mlk/[40C/;f/[mlk/;e/[mlk/N/)*Nw"
echo >t:lsejl{$$} "0(1CL//;n)*Nw"
skip mlk
lab mlk
join t:lsd{$$} t:lsf{$$} t:lsi{$$} TO t:lsc{$$}
sort FROM t:lsc{$$} TO t:lss{$$} COLSTART 6
edit >NIL: FROM t:lss{$$} TO t:lse{$$} WITH t:lsees{$$}
edit >NIL: OPT W186 FROM t:lse{$$} TO t:lsm{$$} WITH t:lsejl{$$}
type t:lsm{$$}
echo ""
run >NIL: delete t:lsd{$$} t:lsf.{$$} t:lsi{$$} t:lsefs{$$} t:lsf{$$} t:lsees{$$} t:lsejl{$$} t:lsc{$$} t:lss{$$} QUIET
run >NIL: delete t:lse{$$} t:lsm{$$} QUIET
Here is how it looks :


Quote:
Originally Posted by redblade View Post
[...] Excellent scripting work Malko
Thank you .
malko is offline  
 
Page generated in 0.04460 seconds with 11 queries