LOGO

Add \

October 20, 2006
Add \

Leveraging Nautilus Scripts in Ubuntu

Ubuntu’s file browser, Nautilus, incorporates a powerful feature allowing the execution of scripts directly on selected files. These scripts extend functionality beyond basic file operations, enabling tasks like file opening, compression, or uploading – essentially, any command-line operation.

Creating a New Script

To begin, a terminal window must be opened. Then, the following command is entered to generate a new script file within the Nautilus scripts directory.

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

This command utilizes the gedit text editor to create a new file named "Open with gedit" in the designated scripts folder.

Script Content

The following script, sourced from the valuable G-Scripts website, should be pasted into the newly created file.

#!/bin/bash
#
# Nautilus script -> open gedit
#
# Owner : Largey Patrick from Switzerland
#     patrick.largey@nazeman.org
# www.nazeman.org
#
# 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)
#
filesall=""
while [ $# -gt 0 ]
do
files=`echo "$1" | sed 's/ /\?/g'`
filesall="$files $filesall"
shift
done
gedit $filesall&

This script is designed to open selected files within a single gedit window. It handles multiple file selections effectively.

Making the Script Executable

After saving and closing the gedit window, the script needs to be granted execution permissions. This is achieved using the following command:

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

The chmod command modifies the file permissions, allowing the script to be run as an executable.

Verification and Compatibility

Tab completion within the terminal can significantly simplify the input of these commands. Following these steps, a right-click menu on any file should now include the "Open with gedit" option. This functionality has been successfully tested on Ubuntu Dapper and Ubuntu Edgy Eft distributions.

Note: The G-Scripts website remains a valuable resource for discovering additional Nautilus scripts to enhance your Ubuntu experience.

#Ubuntu#gedit#right-click menu#context menu#text editor#customize Ubuntu