Creating New Mime Types

As a technical writer by day, I use the Asciidoctor project and asciidoc files to maintain a large suite of user documentation and release notes. I write them in Pluma, which is a pretty awesome editor in my opinion. However, I've lived with an annoying quirk in that its file browser panel does not display *.adoc files. I traced this to an issue with mime-types; asciidoc doesn't really have one so I set about to create one.

So, in this brief tutorial, I'll show you how to create a user-level mime-type using asciidoc as the example.Note that I say this is a user-level association because I haven't been able to find a way to implement this at the system level. Every time I try, the system reverts on a reboot.

  1. Local mime-type associations are stored in ~/.local/share/mime, so open that folder up in Caja and take a poke around
  2. First we will created the package file. Since I want to create one for asciidoc (an extension to a plain text file) I'll create the file text-x-adoc.xml in the packages directory.
  3. Edit the package file as follows:

    Note the glob pattern="*adoc/" tag, that's the file extension.
  4. Next we'll create the text/x-adoc.xml as follows:

    Note you may have to create the text directory if it doesn't already exist
  5. Finally we can update the mime-type database with our new configuration. From the command line:
    $ update-mime-database ~/.local/share/mime
    Note that you may need to restart Caja/Pluma for the changes to take effect at the application level.

It's as simple as that. Note that using this method, you can you can override system-level associations. You can also create new application file types to by using 'application' instead of text and by modifying your app's application file.