Sometimes while going to open a file from Nautilus I do not find the intended application in "open with" menu on right click. Or the desired application remains hidden in a long list of applications. It becomes difficult to find it quickly.
Prior to Ubuntu 11.04 there was a nice feature "Use a custom command" under "open with" menu on right click on a file. One could able write a command in the box to open a file with a custom application. This option is no longer available in Nautilus after Ubuntu 10.10.
Question:
Can I have a similar "Use a custom command" dialogue box on Nautilus so that I can open a file writing any custom command in a box as shown in the above picture?
Here is a small Nautilus script which gives you a "Use a custom command" dialogue box on Nautilus.
The Script
Save the following script as
Open with custom command
in the following directory~/.local/share/nautilus/scripts/
(Ubuntu 13.04 or above)~/.gnome2/nautilus-scripts/
(Ubuntu 12.10 and below)Or you can do it from GUI. Right click on the script, then go to Properties >> Permissions and check the box corresponds to Execute to give the script execution permission.
How it looks like
After that when you right click on a file you could see an option Scripts followed by another option under script Open with custom command.
When you select the option Open with custom command, you will get a dialogue box like,
You can write a command in the box to open the file.
Usage
You can open any file by entering corresponding application's command only in the dialogue box.
For example you can open a
.txt
file usinggedit
or a.pdf
file writingevince
in the dialogue box.Some Other Usage
Open file as root:
If you want to open a file as root, just use
gksudo
before your command. To open a.txt
file as root you can use in the dialogue box,Opening an unknown file:
If you are not sure which application to use to open an unknown file, you can use in the dialogue box,
Opening a file with a Terminal Application:
If you want to open a text file using
vi
, you can use in the dialogue box,Note:
To use
gksudo
you need to havegksu
installed. In Ubuntu 13.04 onwards it is not install by default. You can install it using,