How to open file with gedit with right mouse click in Ubuntu

Recommended Ubuntu book

new gedit window

new gedit window

It may be pretty convenient to open a file in gedit when right-clicking any file, kind of like “open with notepad” option in Windows. You would need to make a new nautilus script, so lets type in this command in the terminal:

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

Basically, this script creates a new file called “Open with gedit” in the the nautilus scripts folder for your user. If it is not working, try gksudo in front of the command, but should be fine as is.

The new gedit file opens up, insert this script code:

 

#!/bin/bash
#
# Nautilus script -> open gedit
#
# Owner : Largey Patrick from Switzerland
#   	  patrick.largey@nazeman.org
#	  www.nazeman.org
#
# Licence : GNU GPL
#
# Copyright (C) Nazeman
#
# Encoding UTF-8
#
# Ver. 0.9-1 Date: 04.04.2003
# Add compatibilty with Nautilus 2.x
#
# 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)
#
curpath=`echo $NAUTILUS_SCRIPT_CURRENT_URI | sed 's/file\:\/\///'`
cd $curpath
filesall=""
while [ $# -gt 0 ]
	do
		files=`echo "$1" | sed 's/ /\?/g'`
		filesall="$files $filesall"
		shift
	done
gedit $filesall&

 

and save the file. Please note, if it will not work, get the code in plain text from here as html may not copy characters correctly.

Now make the script executable. Open terminal window and type:

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

Done. Now lets take a look at your new nautilus script. Right click any file on your desktop and go over “Scripts” menu options. You should now see “Open with gedit”. Click it and you should now be able to open any file in gedit with easy.

Please let us know if you liked the script and if it works well for you.

 

 


3 Responses to “How to open file with gedit with right mouse click in Ubuntu