Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import os, sys
- import subprocess
- HOST_MOUNT_DIR = '\$HOME/ubuntu'
- # get the ip of the host
- host = os.environ['SSH_CLIENT'].split(' ')[0]
- # get the path from $HOME to the file
- file_path = os.path.relpath(os.path.abspath(sys.argv[1]),
- os.path.expanduser('~'))
- # get the path from to the file on the host filesystem
- remote_path = os.path.join(HOST_MOUNT_DIR, file_path)
- # we're going to use the default editor on the host
- args = '/usr/bin/ssh %s "\$EDITOR %s"' % (host, remote_path)
- print args
- subprocess.Popen(args, shell=True)
Add Comment
Please, Sign In to add comment