lsd icon indicating copy to clipboard operation
lsd copied to clipboard

Add support for file category sort

Open devnoname120 opened this issue 3 years ago • 4 comments

Enhancement of https://github.com/Peltoche/lsd/pull/413

The problem

Currently, if you have media files such as .mkv, .mp4, and .webm they won't appear together but instead be spread out. Same for .jpg and .png which is pretty annoying.

Proposed solutions

Sort by icon

An easy improvement would be to sort on (icon, extension) as currently many file types belonging to the same category have the same icon (e.g. .mp4, .mov, .mkv).

Sort by mime type

An alternative would be to rely on the mime media types but it's far from perfect:

  • Some file types are in several categories, with some that don't make sense.
    • e.g. mp4 is application/mp4, audio/mp4, and video/mp4
  • The granularity is poor. There are only 10 categories: application, audio, font, example, image, message, model, multipart, text, and video.

Sort by custom category definitions

A better improvement would be to embed a simple hierarchical category system, where formats are put in the category that makes the most sense. The ordering would be on the key (category, extension).

For example it could look like that:

video:
  compression: [h264, h265]
  container: [avi, mp4, mkv]
audio:
  compression: [aac, opus, mp3, wma]
  container: [ogg, wav]
text:
  plain: [txt, log]
  formatted: [md]
  code:
    system: [c, cpp, go]
    web: [html, js, css]
    script: [py, sh] 

Etc.

devnoname120 avatar Aug 09 '22 22:08 devnoname120

This is an interesting idea, but as you said, not sure what would be the best way to categorize things. Doing by icons can become messy as we might have custom image formats with separate icons (like things from Adobe). Doing it by mime sounds like an interesting option but we might miss out of some useful ones like document(pdf, docx).

meain avatar Aug 12 '22 04:08 meain

I really like the idea of Sort by custom category definitions. LSD could provide a default category definition and users can create their own in .config/lsd/ to extend/overwrite the default one if they want.

strahlc avatar Mar 07 '23 09:03 strahlc

+1

strahlc avatar Mar 07 '23 09:03 strahlc

I have too much on my plate right now, otherwise I would love to do a PR. Anyone would like to step in? 🙏

devnoname120 avatar Mar 07 '23 12:03 devnoname120