Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I found a nautilus script I would like to use. How do I install it?

share|improve this question
add comment

1 Answer

up vote 14 down vote accepted

Say you want to install the following script you found while browsing Ask Ubuntu:

#!/bin/bash
## Sample Script 0.1
## Dependencies: notify-osd

notify-send "Sample nautilus script" "You Selected $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"

Dependencies

The first thing you'll notice is that many scripts won't just run out of the box. Sometimes they depend on other packages you might or might not have installed. In this case our script depends on notify-osd, which comes with Ubuntu by default.

On other distros this might not be the case and you'll have to install the dependencies before using the script. If the dependency is part of the official repositories you can easily install it with apt-get, e.g.:

sudo apt-get install notify-osd

Setting the script up

Now that we've satisfied all dependencies we can move on and copy the script to our system. To do so we first create a new document in our scripts folder, which is ~/.gnome2/nautilus-scripts or ~/.local/share/nautilus/scripts/ on Ubuntu 13.04 and above. This is a hidden folder. In order to head to it you will have to open your file manager, press CTRL+L and paste the directory path into the Location bar.

Next we will create a new empty document by right clicking and selecting Create new DocumentEmpty Document. Name it anything you want, but beware: The title you choose is how the script entry will later appear in the nautilus context menu. So better choose a descriptive name for the document:

enter image description here

Open the new document up in a text editor of your choice and proceed to copy and paste the contents of the code box above into it. Save it and exit the text editor.

Making it executable

At this point your script is set up correctly but still won't work as the system does not recognize it as an executable file yet. To make it executable, right click on your file and head to PropertiesPermissions. Set the checkmark at Allow Executing as program and close the dialogue:

enter image description here

Usage

You should now be able to access the script from your nautilus context menu. Just right click on a file of your choice and head to Scripts --> Script name (here: Sample Script). Click on the entry to execute the script on the files you selected:

enter image description here

Automating the installation

You can install a nautilus script to automate the installation of nautilus scripts:

#!/bin/sh
# make_nautilus_script: copies the selected file(s) to ~/Nautilus/scripts
# and makes it executable.  It will overwrite without warning.
for arg 
do

 cp "$arg" ~/.gnome2/nautilus-scripts/
 chmod u+x ~/.gnome2/nautilus-scripts/"$arg"

done

Based on this script and modified to work on recent Ubuntu releases.


Enjoy!

P.S.: Here's the nautilus script I used to record the screencasts of this very answer.

share|improve this answer
1  
Nice answer with screen cast. :) –  TheKojuEffect Feb 13 at 2:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.