Nautilus “Open in Remote Terminal”

Nautilus is the official file manager for the Gnome desktop. I use it for browsing local file system as well as SFTP servers.

One cool feature I was missing when I started using this file manager was ability to open current directory in terminal, no matter if I am in local file system or remote server. After some googling I find out that there is nautilus plugin nautilus-open-terminal which allows you to open terminal in current folder via right click context menu. This plugin works perfect in local file system, but for some reason, it crashes for remote sessions. If it fails for you as well, keep reading…

I reported a bug about this failure, but got no response, so I decided to write my own script to do the job.

Nautilus is extensible through the use of scripts. All you have to do is to copy your script to ~/.gnome2/nautilus-scripts, restart Nautilus, and you can run it from right click menu.

With some help of stack folks I wrote a python script to make SSH connection to current host with current user, and navigate to current folder in remote terminal. See code below.

#!/usr/bin/env python
# Opens current directory in remote terminal via SSH.

import os
from urlparse import urlparse

# parse uri
uri = urlparse(os.environ['NAUTILUS_SCRIPT_CURRENT_URI'])

# ssh
os.system('gnome-terminal --execute /usr/bin/ssh -t {} \' cd {} ; exec "$SHELL"\''.format(uri.netloc, uri.path))

Code is on github, so feel free to fork and improve it.

After install (make sure to grant exec privileges on script) you can access it from right click menu.

Use script from right click menu

Use script from right click menu


I usually have bookmarks for most frequently used remote locations, and with the help of this script I can be there in two clicks.

I hope someone will find this script useful.

  • goran

    Use KDE :) KDE based editors have this feature out of the box :)