lsd-rs / lsd

The next gen ls command
Apache License 2.0
13.6k stars 438 forks source link

[Feature request] Second level sort method (for --sort=extension) #814

Open hasecilu opened 1 year ago

hasecilu commented 1 year ago

Expected behavior

Be able to have a nested sort option over the main one. This will allow user to nest sorting methods (if applicable). Sort by name is absolute, there is no space for a "second level sorting method" Sort by extension groups files but don't seem to be an order in them (per group/section) by name nor time nor size.

A good option could be able to specify a second level sort method, in my case I prefer by name and if it's used with --sort=extension each "extension group" will sort its files alphabetically allowing the user to find faster specific file(s). Very useful with a long list of files. It's very common to find this setting in graphical file browsers.

Actual behavior

The default sort order is by name, files with same extension are separated.

$ lsd --icon never
2022-09-13 (2).png   Avanxe7.zip  ID_394_507.zip       p5000      venus_box_cover_mod.stl  VID_20220819_175931.mp4
20221204_121637.mp4  BPSK         image.png            Solid.png  vernier_caliper.FCStd    
asmdemo.c            Day7.c       oboi7.com-14695.png  TS80P.zip  VID_20211227_175134.mp4 

If the sort order is by extension, files with same extension are grouped but each group itself is not sorted by name.

$ lsd --icon never --sort=extension
BPSK                   Day7.c                   2022-09-13 (2).png   venus_box_cover_mod.stl
p5000                  VID_20211227_175134.mp4  oboi7.com-14695.png  ID_394_507.zip
vernier_caliper.FCStd  VID_20220819_175931.mp4  Solid.png            Avanxe7.zip
asmdemo.c              20221204_121637.mp4      image.png            TS80P.zip

Is better

$ lsd --icon never --sort=extension
BPSK                   vernier_caliper.FCStd       022-09-13 (2).png       venus_box_cover_mod.stl
p5000                  20221204_121637.mp4         image.png               Avanxe7.zip
asmdemo.c              VID_20211227_175134.mp4     oboi7.com-14695.png     ID_394_507.zip
Day7.c                 VID_20220819_175931.mp4     Solid.png               TS80P.zip
hasecilu commented 1 year ago

Things to note:

raabrp commented 1 year ago

If you don't mind the inefficiency of running ls first, I'm currently using the following work-around to get the sorting that I prefer from ls with the display niceties of lsd (zsh shell on Fedora 38):

alias ll="ls -1X --sort=extension --group-directories-first --color=never | xargs lsd -Uld"