In earlier versions of Ubuntu (10.10-) there was an option in the "open with" tab in the properties window, to add a custom command to open a file. However, this is no longer the case in Ubuntu 11.10. Is there any way that I can add these file type associations with a command of my choice rather than the applications detected by the system.
How to Add Custom Command in ‘Open With’ Dialog
gnomenautilus
Best Answer
As aneeshep's answer explains, the key is creating an appropriate
.desktop
"launcher". But there's a simpler way than doing it by hand; in many cases, you may not even need to edit the.desktop
file.Solution: Use Ubuntu Tweak
.desktop
file which you can edit further for your needs, e.g. if you are using a command-line editor or program to open, etc.In this how-to, we look at how to set up Nautilus to open
.php
files in the free Komodo Edit GUI text editor, which comes with a shell-installer that installs it in your home directory by default; the program/command is then/home/user/Komodo-Edit-7/bin/komodo
1. Install Ubuntu Tweak
Add its PPA, update and install Ubuntu Tweak from the terminal with:
Update: Check this question for updated instructions for newer Ubuntu releases
2. Find the MIME description for your file extension
Open Nautilus, find one of the files we want (here,
.php
), right-click on it and click on Properties:In the Properties window which comes up, note the text shown just after Type:; that's the MIME description we're looking for (here, "PHP Script"):
3. Add a custom program to open your filetype
Start Ubuntu Tweak from the Dash, and click on the Admins tab on top; then click on the File Type Manager entry on the bottom:
After the File Type Manager opens, click on All in the left sidebar, and uncheck the Only show filetypes... box at the bottom:
Select any filetype on the right side, and begin typing the first few letters of the MIME description from Step 2 to automatically search and select your filetype:
Double-click on your filetype, which is now selected, to edit its associated commands.
PHP files will now open in Komodo by default, as seen in the Properties below; press the Reset button to go back to the default for that filetype: