xdg-mime default nvim.desktop text/plain
We can get the file’s mime-type through
xdg-mime query filetype /path/to/the/file, and using
xdg-mime default <application> <mimetype(s)> to set the default application for those files.
application is a .desktop file.
If you want to edit configuration manually or feel really desperate, just modify the
Just add it under the
[Default Applications] section if you
want to be default, or under the
section if it shouldn’t be default.
Note: Some programs still use the now deprecated
~/.local/share/applications/mimeapps.list, however the best is to make that a symlink to
~/.config/mimeapps.list to have a single config for this: