Note to self:

Sunday August 16th 2009 - 22:26


Was the solution

Linux / Ubuntu / Nautilus / bash / shell / "open with"

Thursday May 14th 2009 - 05:00

Nautilus scripts
Opening a file with a specific application is an easy task - simply right click it and select the appropriate application from the "Open With" submenu.

But what if you're not trying to open the file with an application? What if you regularly need to incorporate a file in a specific shell command?

I had this problem recently, and it turns out there is an ingenius little function within Nautilus to address exactly this. I present to you the "Nautilus script". And without further delay, a real life example and a quick description of how it works.

gnome-terminal -x unrar e "$@"

The first line is the so-called bang line, it tells your computer that this is a script and what kind of tools it should use to execute the script. In this instance we see that this is a shell script, indicated by the path to the shell.

gnome-terminal -x tells us that this command should be executed in a visible terminal, as opposed to just running and not letting the user know what is going on. This part can be left out if you don't feel the need to have a terminal window open while your command runs.

unrar e is a command I use on a regular basis, it runs the unrar program with the instructions to extract the contents on the following filename. This is just and example. You can substitute it for your own commands, add more lines with more commands and so on. Note that is you fo want to use this particular command, you will need to have the 'unrar' application installed.

And last but not least, the most important part of the script, "$@" is a placeholder for the complete path to the file we are opening with the script.

Once we have assembled our script and saved it to a file with a name of our choosing (the filename will appear in the right click menu) we need to place the script into the nautilus-scripts folder located inside your home folder.
Typically this can be found here:


Note that the .gnome2 folder's name starts with a dot, indicating it should be a hidden folder. If you are browsing to this location you will need to hit ctrl + h to see hidden folders.

Also note that username should be the same as the username you use to log on to your computer.

There are quicker ways to copy files than browsing around, use your prefered method of course!

One last thing that remains to be done before you can use your new toy is to make the script executable. Right click the file and select 'Properties', navigate to the 'Permissions' tab and tick the 'Execute' checkbox. Alternatively use your prefered method to chmod the file to become executable.
Once you have copied your script into the nautilus-scripts folder and it is flagged as executable, you can access it by right clicking any file and mousing over 'Scripts'. The script should appear in the menu and you can click on it to execute it with the filename of the file you right clicked substituted wherever the placeholder occurs in your script.



Frigate Fight Extravaganza


Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed tellus odio, convallis in, faucibus nec, dapibus nec, libero. Ut non velit. Donec convallis. In hendrerit, risus eleifend convallis laoreet, felis sem dictum leo, ut hendrerit libero dui ac pede. Aliquam erat volutpat. Integer porta. Etiam ut ante nec augue euismod semper. Donec tincidunt turpis. Nulla posuere cursus quam. Vestibulum ut neque sed mi tincidunt rhoncus. Aliquam scelerisque, lacus et ultricies sagittis, tellus ante consectetuer dui, nec gravida massa leo ut ligula. Vestibulum rutrum adipiscing velit. Nullam sit amet tellus sed quam viverra pellentesque.

Aenean velit. Nam id lacus. Sed posuere ipsum eu sapien. Donec odio orci, ultricies et, pellentesque eget, venenatis hendrerit, ante. Donec dictum dignissim metus. In adipiscing leo a augue. Mauris faucibus enim sit amet est. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent vel nisl. Mauris consectetuer, augue eu rutrum vehicula, ante metus facilisis urna, eget tempor lectus tellus a lacus. Cras turpis est, pharetra quis, cursus in, viverra sit amet, erat. Cras facilisis, odio nec rhoncus malesuada, nulla nulla venenatis risus, non cursus pede justo sed dolor.

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed sed sapien et sem suscipit commodo. Sed id erat non nibh aliquet egestas. Nulla magna justo, blandit sit amet, blandit a, mollis at, leo. Ut aliquet. Quisque turpis. Duis mattis. Aenean at nulla. Morbi ut est. Proin dapibus nisi cursus leo.

Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce commodo semper sapien. Nullam molestie nunc non nibh. Aenean gravida ipsum vel purus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vivamus rhoncus mi eget massa. Ut luctus quam id magna. Nam consequat lorem id justo. Vestibulum magna. Mauris egestas dui vel arcu aliquam luctus. Suspendisse faucibus lectus in lectus. Praesent metus nunc, ultricies vitae, commodo sollicitudin, dignissim nec, dolor. Donec malesuada rhoncus nisl. Duis vehicula metus ut dolor. Ut faucibus tortor pretium elit.

Maecenas velit turpis, consequat eu, tempus eu, consequat id, dolor. Etiam suscipit. Suspendisse potenti. Suspendisse quis elit non magna pretium tempus. Vivamus eros. Donec risus ipsum, dapibus non, fermentum eget, malesuada vitae, sapien. In consequat augue. Suspendisse potenti. Etiam malesuada adipiscing elit. Ut tempus urna in arcu. Vivamus non magna. Morbi volutpat.