Here is a small Nautilus script which gives you a "Use a custom command" dialogue box on Nautilus.
- Save the following script as
Open with custom command in your
~/.gnome2/nautilus-scripts/. If you are using Ubuntu 13.04 or above, you need to put the script in
var=$(zenity --entry \
--title="Add Application" \
--text="Use a custom command" \
if [ $? -eq 0 ] && [ "$var" ]; then
- Give the script execution permission. It is important, otherwise no change will take place. You can use in terminal,
chmod +x ~/.gnome2/nautilus-scripts/Open\ with\ custom\ command
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.
You can open any file by entering corresponding application's command only in the dialogue box.
For example you can open a
.txt file using
gedit or a
.pdf file writing
evince 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,
gnome-terminal -x vi
gksudo you need to have
gksu installed. In Ubuntu 13.04 onwards it is not install by default. You can install it using,
sudo apt-get install gksu