Add “Open with gedit” to the right click menu in Ubuntu

August 11, 2008

The file browser in Ubuntu provides the ability to run scripts on a selected file. These scripts can be used to do anything from opening a file to zipping or uploading, or anything that you can do from the command line.

To start off, we will need to open a terminal window and type in the following command, which will create a new script file in our nautilus scripts directory

gedit ~/.gnome2/nautilus-scripts/Open\ with\ gedit

Paste in the following script, found on the G-Scripts site, which is a great resource for finding scripts.

# Nautilus script -> open gedit
# Owner : Largey Patrick from Switzerland
# Licence : GNU GPL
# Copyright (C) Nazeman
# Ver. 0.9-1 Date: 16.02.2002
# Add multiple file open in the same windows
# Ver: 0.9  Date: 27.10.2001
# Initial release
# Dependence : Nautilus (of course)
#   Gnome-utils (gdialog)
while [ $# -gt 0 ]
files=`echo "$1″ | sed ‘s/ /\?/g’`
filesall="$files $filesall"
gedit $filesall&

Save and close the gedit window, and then execute the following command to make the script executable:

chmod u+x ~/.gnome2/nautilus-scripts/Open\ with\ gedit

Note that tab completion really helps here =)
Now when you right click a file, you should see this:

Tested on: Ubuntu Dapper, Ubuntu Edgy Eft


Powered by Computer 2000


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: