fd icon indicating copy to clipboard operation
fd copied to clipboard

Adding mimetype support

Open Baerbeisser opened this issue 1 year ago • 2 comments

Like in xdg-mime query filetype some-video.webm displaying video/webm, parameters could be -M video, -m webm or something. Would that be possible? I quess it would hurt performance. I was always wondering, Linux Desktop is mimetype based first, file extension second. But the good old command line tools are always string only. Have missed this feature often in find.

Baerbeisser avatar Jul 02 '23 20:07 Baerbeisser

I'm looking to make some contributions, is this a feature that makes sense for fd? (I understand it's not trying to be a complete find replacement).

There are a couple of different approaches to listing the mime type discussed here: https://github.com/bojand/infer/issues/24

I've got an example implementation that would use first attempt to get the mimetype using infer (magic number), and then falling back to the file extension database using mime_guess: https://github.com/xweskingx/fd/pull/1/commits/8400b88270d3491738bd1afd5c0d1bc86f92ed47

xweskingx avatar Oct 08 '23 18:10 xweskingx

To be honest, I'm rather leaning towards declining this feature request. But see #400 for a discussion on a more generic version of this.

sharkdp avatar Oct 21 '23 11:10 sharkdp