Original editing of a remote file using emacs tramp from an ssh session

This is probably a somewhat stupid question. I use tramp to edit remote files, but I also open several terminals for this remote machine, as well as for other work (I had problems running the ssh shell inside emacs).

Often during terminal operation, I would like to edit some file, and my current procedure is to copy the file name and then use emacs tramp to open this file (after randomly accessing the file path in tramp format). This is too much work for quick editing and errors associated with the error in the processing part of the path.

The question is: can I execute some command in a remote ssh session that accepts the file name, convert it to tramp format (which is the easy part) and run a local command (e.g. emacsclient blahblahblah ) so that I can edit the remote file using tramp in local emacs?

I'm not sure how clear I am. I do not want to run emacs on a remote computer (either on a terminal or through an x ​​session), but I want to send the file to local emacs from a remote prompt, for example:

 user@remote-machien ~/ $ run_local_emacs somefile # then the file "/ssh:user@remote-machine/:/home/user/somefile" shows up # in my local emacs 
+12
ssh emacs tramp
Feb 09 '10 at 19:32
source share
5 answers

You can configure your emacs server to use the tcp connection (and not just the local socket), and then remotely tell emacsclient about the tcp connection to this connection:

In your .emacs

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

And then on the far side:

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

The above emacsclient call calls the local file on the “remote” machine in your Emacs running on the local machine. Obviously, you can wrap the emacsclient call in any kind of script that you want to facilitate.

If your home directory does not appear on the remote computer, you will need to configure the server-auth-dir variable as follows:

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

For more information, see Emacsclient Options .

+12
Feb 09 '10 at 19:58
source share
— -

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

Enables remote directory tracking, which allows tramp to open deleted files as if they were local

+1
Mar 16 '11 at 16:10
source share

You can use urxvt (a great terminal emulator) and write the perl extension to do this, even if emacsclient is not installed on the remote computer.

0
Feb 10 '10 at 9:52
source share

You may already know about this, and it won’t work for you, but when I needed to do such things, completing the file name in TRAMP was quite useful, you never thought of looking for alternatives.

Cx Cf /ssh:remotehost:/ Tab Tab

This works best if you have SSH keys or similar access without a password, but it looks like you already have it.

0
Sep 28 '15 at 18:21
source share

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

 me@remote-machine$ ssh -f me@local-machine emacsclient /ssh:remote-machine/$(realpath my-file-name) 
0
Oct 07 '15 at 9:01
source share



All Articles