I’m back from my vacation and this is a smallish post before we return to our regular programming (I’m full of puns
).
Rahul (my friend and guest author on this blog) introduced me to an old-but-useful trick a few days ago that I didn’t know about. It’s about customizing nautilus to display a context menu that has a few of your chosen scripts to weave their magic on the selected object. And the procedure to do this is summarized in just two steps:
- Write your script.
- Save it in ~/.gnome2/nautilus-scripts and make it executable (chmod +x <script name>).
Of course, if you don’t know scripting the first step itself is quite daunting, but you can get a lot of pre-cooked scripts on the internet by searching for “nautilus scripts”. e.g. take a look at g-scripts homepage.
To get you started immediately, here is a crude example to open a terminal/console window in any folder/path through right-click menu:
Step 1) Write your script (any scripting language: shell, perl, python, etc):
#!/bin/bash gnome-terminal --working-directory="$1"
Step 2) Save it in ~/.gnome2/nautilus-scripts, name it as “Terminal” and make it executable.
chmod +x Terminal
Step 3) Now, you should see a “Scripts” option in your right-click menu as shown below. Clicking on “Terminal” will open a new terminal window with the present working directory being set to the selected folder.
Note: If you don’t see the “scripts” menu option (or your script name in the extended menu), then just run
sudo killall nautilus
Let me know if you face any problems with this or have any other questions.
[tags]ubuntu, tip, nautilus-scripts, nautilus scripts, g-scripts, gscripts, shell script, nautilus, terminal[/tags]



For me it only opens the terminal in my Home directory no matter what directory Nautilus is open in.
Three tips:
1) It would be more useful if you listed which environment variables are available from within Nautilus, so that I could use those in my own scripts, like the current working directory, and how to get the Nautilus window to do various things, like refresh itself, open a new instance, make it move to another directory, etc, etc.
2) A more involved example would be useful.
3) How to make scripts generally available to all users, i.e. is there some /etc/gnome2/nautilus-scripts directory where you put scripts that you want to appear in everyones nautilus menu?
Thanks for the valuable inputs, Perpetual Rabbit. I’ll follow up on this article with the answers to queries as put forward by you.
Cuba Dveri.Ru- оптовая продажа межкомнатных дверей в Mоскве от отечествоенных производителей. Мы предлагаем :продажа межкомнатных дверей,продажа стальных дверей.
Thanks and I know it old but it sorta got me on the right track searching for something else, anyway to get your script to work properly in jaunty ubuntu…
gnome-terminal –working-directory=”–directory”
I have few more UBUNTU Tricks;
http://www.itoperationz.com/2010/01/install-ubuntu-linux-on-windows-just-like-an-application/