Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 3110  / 1 Year ago, wed, may 3, 2023, 7:31:05

I am creating a new file either by using



in terminal: touch newfilename.someext



or



in nautilus: File > Create New Document > Empty Document



The file takes on the type "plain text document" and gets associated with the default text-editor. How can I turn-off these 2 actions?



The .somext is a new/unknown extension and I expect the system to show it as an unknown file type.



Edited August 10 2012:

I noticed that if you have a non-printing binary character in the file, then it will show as type "Unknown".


More From » mime-type

 Answers
1

Your question is all about MIME types.



MIME type is resolved not only by file extension (glob patterns), but also by file contents (magic rules).



See http://library.gnome.org/admin/system-admin-guide/stable/mimetypes-modifying.html.en#-note-id301200:




When no glob patterns or magic rules match a file, then it is resolved
to the MIME type text/plain if it contains textual data or
application/octet-stream for binary data. If the file is empty, then
it defaults to text/plain.




So exactly as you noted, file with unknown extension is resolved to text/plain, but if it contains binary data, it is resolved to application/octet-stream, which is shown as "Unknown" (if you are curious why, search for "application/octet-stream" in /usr/share/mime/packages/freedesktop.org.xml).



If you need to register new extension and associate some application with it, you should first register new MIME type, associated with desired extension, and then associate some application with this new MIME type. The following links explain this:





If you don't need to register new extension, I don't see any reason to change the default behavior (resolve text data to text/plain). It's natural.


[#36608] Thursday, May 4, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
inglehare

Total Points: 330
Total Questions: 111
Total Answers: 95

Location: Sint Maarten
Member since Tue, Mar 29, 2022
2 Years ago
;