-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"Open in remote terminal" option was missing in nemo context menu. Added the option by creating a new in-built action in /usr/share/nemo/actions which runs a python script to invoke ssh in terminal. More detailed benefits can be found in #2824
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Nemo Action] | ||
Name=Open in Remote Terminal | ||
Comment=Open a remote terminal in the active remote folder | ||
Exec=<remote_terminal.py %F> | ||
Icon-Name=utilities-terminal-symbolic | ||
Selection=any | ||
Extensions=dir; | ||
# conditions=exec <remote_terminal.py %U>; | ||
Dependencies=ssh; | ||
UriScheme=sftp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/python3 | ||
# -*- coding: utf-8 -*- | ||
# On linux-systems, root an sftp location is mounted at: | ||
# /run/user/<uid>/gvfs/sftp:host=<host-ip> | ||
|
||
import os | ||
import sys | ||
import subprocess | ||
|
||
# terminal application | ||
terminal="x-terminal-emulator" | ||
|
||
# remote uri | ||
uri = sys.argv[1] | ||
print(uri) | ||
# remote user | ||
remote_user = os.environ['USER'] | ||
|
||
host_full_path = uri.split('sftp:', 1)[1] | ||
|
||
ssh_args = {} | ||
ssh_args['remote_user'] = remote_user | ||
remote_host, sep, ssh_args['remote_path'] = host_full_path.partition('/') | ||
|
||
name, sep, remote_ip = remote_host.partition('=') | ||
ssh_args['remote_ip'] = remote_ip | ||
|
||
# run ssh command | ||
remote_cmd = [terminal, '-e', | ||
'ssh %(remote_user)s@%(remote_ip)s -t "cd /%(remote_path)s; $SHELL"' % ssh_args] | ||
subprocess.call(remote_cmd) |