Originate edit of remote file using emacs tramp from ssh session

馋奶兔 提交于 2019-11-27 14:06:02

You can set up your emacs-server to use a tcp connection (not just a local socket), and then on the remote side, tell emacsclient to connect to that tcp connection:

In your .emacs

(setq server-use-tcp t)
(setq server-host "name_of_local_machine")
(server-start)

And then on the remote side:

emacsclient -f ~/.emacs.d/server/server /`hostname`:/path/to/local/file

The above call to emacsclient brings up a file local to the "remote" machine in your Emacs running in the "local" machine. Obviously you can wrap the call to emacsclient in whatever kind of script you want to make it easier.

If your home directory is not visible on the remote machine, you will need to customize the server-auth-dir variable like so:

(setq server-auth-dir "/some/path/visible/on/both/machines")

For more documentation, see Emacsclient options.

Theres also http://www.emacswiki.org/emacs/AnsiTermHints#toc4

Incorporates remote directory tracking which lets tramp open remote files as if it was local

You can use urxvt (an excellent terminal emulator) and write a perl extension to do this even if emacsclient isn't installed on the remote machine.

Maybe you already know about this and it doesn't work well for you, but when I've needed to do that sort of thing the filename completion in TRAMP has been helpful enough that I've never thought of looking for alternatives.

C-xC-f/ssh:remotehost:/TabTab

This works best when you've got SSH keys or similar passwordless access set up, but it sounds like you have that already.

What I am doing here is a reverse ssh connection from remote to local and running emacsclient locally:

me@remote-machine$ ssh -f me@local-machine emacsclient /ssh:remote-machine/$(realpath my-file-name)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!