Ubuntu – Make shell script default to run file extension

appmenudefaultdefault-programsmenuscripts

I'm trying to make the default application for .asm file extension to be a shell script that I made. Basically I have a .sh script that runs MIPS Mars and I want to make it the default application to open assembly .asm files. My problem is that while I can add my .sh script to the app menu using main menu app from the store, I can't make my script appear in the list of open with programs for .asm files.

Best Answer

You can try creating a .desktop file in /usr/share/applications (or ~/.local/share/applications, if only for one user) like explained here (works for other desktops too).

To link this program to .asm files you first have to create a mimetype for .asm files.

In order to do so you have to add/modify the line

text/x-asm                asm

in /etc/mime.types

In the .desktop file you should add the line

MimeType=text/x-asm;

so it's added to the "Open with" menu.

To finally make your script the default application for .asm files add

text/x-asm=yourscript.desktop

to /usr/share/applications/defaults.list

Edit: To make it work immediately you should probably run update-desktop-database after your changes.