This is probably a somewhat out-of-wack question. I use tramp to edit remote files, but I also open several terminals ssh-ing to that remote machine as well for other works (I had problems running ssh shell inside emacs).
Often times during the terminal work I would like to edit some file, and my current procedure is to copy the file name, and then use emacs tramp to open that file (after messing all around with getting the file path in the tramp format). This is way too much work for a quick edit and quite error prone in the path handling part.
The question is: Can I execute some command in the remote ssh session that takes the filename, transform that to tramp format (that's the easy part), and run a local command (like emacsclient blahblahblah
) so that I can edit the remote file using tramp in my local emacs?
I'm not sure if I'm clear enough. I don't want to run emacs on the remote machine (either on the terminal or through an x session), but I do want to send file to my local emacs from a remote prompt, like this:
user@remote-machien ~/ $ run_local_emacs somefile
# then the file "/ssh:user@remote-machine/:/home/user/somefile" shows up
# in my local emacs
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With