eza-community / eza

A modern alternative to ls
https://eza.rocks
MIT License
11.02k stars 197 forks source link

feat: use mimetype to determine filetype in linux #1073

Open Rid1FZ opened 1 month ago

Rid1FZ commented 1 month ago

As far as I noticed, eza uses some sort of regex or file extension to determine filetype. But it is very common in linux to fully avoid extension for any script for example. In that cases, eza shows default icon for that file (which is incorrect). Is it possible to use mimetype instead for filetype detectiom in linux? Mimetype of any file is detected by reading the file instead of using anything like regex. It helps to determine filetype more precisely.

gierens commented 1 month ago

You are correct, at the moment the filename/extension is used to determine the type. We are not using the mime/content type as far as I'm aware.

As for adding this functionality, sure that is possible, we would first have to check how to do it efficiently, though. If we really have to read the file, even just partly, this will likely incur a decent amount of overhead, so it would probably be best to put it behind a command line flag to enable it rather than making it the default behavior.

cafkafk commented 1 month ago

As for adding this functionality, sure that is possible, we would first have to check how to do it efficiently, though. If we really have to read the file, even just partly, this will likely incur a decent amount of overhead, so it would probably be best to put it behind a command line flag to enable it rather than making it the default behavior.

Ideally we would also start measuring that overhead, so we could make informed choices... but then again, we really need some way to catch performance regressions in reviews