Comment 1 for bug 1119283

Revision history for this message
Thimo Kraemer (thimo-kraemer) wrote :

You could create two actions in ~/.local/share/nemo/actions.

File remote_terminal1.nemo_action:

[Nemo Action]
Name=Open in remote terminal
Comment=Open current folder in remote terminal
Name[de]=Im entfernten Terminal öffnen
Comment[de]=Aktuellen Ordner im entfernten Terminal öffnen
Exec=<remote_terminal.py %F>
Icon-Name=terminal
Selection=none
Extensions=dir;
Dependencies=ssh;

File remote_terminal2.nemo_action:

[Nemo Action]
Name=Open in remote terminal
Comment=Open this folder in remote terminal
Name[de]=Im entfernten Terminal öffnen
Comment[de]=Diesen Ordner im entfernten Terminal öffnen
Exec=<remote_terminal.py %F>
Icon-Name=terminal
Selection=s
Extensions=dir;
Dependencies=ssh;

And finally a Python script remote_terminal.py:

#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import sys
import subprocess

path = sys.argv[1]

if '/sftp:' in path:
    sftp = path.split('/sftp:', 1)[1]
    settings = {}
    options, sep, settings['path'] = sftp.partition('/')
    for opt in options.split(','):
        name, sep, value = opt.partition('=')
        settings[name] = value

    cmd = ['gnome-terminal', '-e',
        'ssh %(user)s@%(host)s -t "cd /%(path)s && bash --login"' % settings]
else:
    cmd = ['gnome-terminal', '--working-directory', path]

subprocess.call(cmd)