12 October 2021, 14:29 | #1 |
Ex nihilo nihil
Join Date: Oct 2017
Location: CH
Posts: 5,137
|
AmigaOS 1.3 ' ls ' command
Building on the momentum of my previous achievement with the AskL/AskM commands & the use of environment variable in WB 1.3 scripts, I decided to try to script another thing that I missed BitD : an 'ls' command (by this I mean : a columned and coloured listing of a given folder).
As previously, any comments or tips to improve the way it has been done are welcome. NEW VERSION OF THE SCRIPT AVAILABLE BELOW. SEE POST #8 Code:
ls : .key repertoire .bra { .ket } .def repertoire "" echo >NIL: t:lsefs "0(f/.info/;d )*Nw" echo >NIL: t:lsees "0(f/[mlk/;e/[mlk/[26C/;f/[mlk/;e/[mlk/[52C/;f/[mlk/;e/[mlk/N/)*Nw" echo >NIL: t:lsejl "0(2CL//;n)*Nw" list >t:lsd "{repertoire}" dirs lformat="*e[33m%s*e[1E*e[1A*e[mlk" list >t:lsf "{repertoire}" files lformat="*e[31m%s*e[1E*e[1A*e[mlk" list >t:lsi "{repertoire}" files pat=#?.info lformat="*e[32m%s*e[1E*e[1A*e[mlk" edit >NIL: FROM t:lsf TO t:lsf. WITH t:lsefs join t:lsd t:lsf. t:lsi TO t:lsm sort FROM t:lsm TO t:lsm. COLSTART 6 edit >NIL: FROM t:lsm. TO t:lsm.. WITH t:lsees edit >NIL: FROM t:lsm.. TO t:lsm. WITH t:lsejl delete t:lsefs t:lsees t:lsejl t:lsd t:lsf t:lsi t:lsf. t:lsm t:lsm.. QUIET type t:lsm. delete t:lsm. QUIET echo "" Last edited by malko; 13 October 2021 at 22:45. |
12 October 2021, 15:55 | #2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,047
|
On the List command you don't need quick if you have lformat. Quick is like lformat=%s.
|
12 October 2021, 16:24 | #3 |
Ex nihilo nihil
Join Date: Oct 2017
Location: CH
Posts: 5,137
|
Thank you thomas .
Source in 1st post has been updated accordingly. |
13 October 2021, 03:31 | #4 |
Registered User
Join Date: May 2018
Location: Ireland
Posts: 722
|
Sorry if OT but did any Amiga OS have "ls" command?
I know "dir" works, but just seems a bit unconventional that it wasnt "ls" by default as its more aligned with Unix than DOS. |
13 October 2021, 09:18 | #5 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,047
|
"Dir" gives sorted list of names only.
"List" gives unsorted list of details with the option to reformat the output. So List is what comes next to ls. And I don't see why AmigaOS should align with anything. Especially if it's worse than what we have. |
13 October 2021, 12:20 | #6 |
Registered User
Join Date: Oct 2009
Location: Germany
Posts: 3,325
|
PFS comes with an unix like ls command.
|
13 October 2021, 21:24 | #7 |
Zone Friend
Join Date: Mar 2004
Location: Middle Earth
Age: 40
Posts: 2,130
|
Imimmfn: AmiTCP 4.x came with 'ls' in the /bin/ directory, possibly GNU AmiTCP version 2.x and 3.x as well.
Excellent scripting work Malko Last edited by redblade; 13 October 2021 at 21:47. |
13 October 2021, 22:43 | #8 |
Ex nihilo nihil
Join Date: Oct 2017
Location: CH
Posts: 5,137
|
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 Thank you . |
13 October 2021, 23:34 | #9 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,374
|
|
19 November 2021, 16:43 | #10 |
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
|
I like the colours
|
19 November 2021, 21:09 | #11 |
Ex nihilo nihil
Join Date: Oct 2017
Location: CH
Posts: 5,137
|
Thanks . I think it helps finding a files as you can focus your eyes on the needed colour
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Is there a WB command at all that can... | MethodGit | request.Other | 43 | 10 October 2010 09:06 |
What is the WB command that..... | MethodGit | request.Other | 4 | 08 October 2010 04:21 |
The 'FreeAnim' command | MethodGit | request.Apps | 5 | 14 June 2009 14:43 |
Assign command | fc.studio | support.Apps | 2 | 28 December 2005 18:36 |
final command | runamuck | request.Old Rare Games | 10 | 23 September 2003 20:55 |
|
|