Hacker News new | ask | show | jobs
by db48x 875 days ago
Best solution to that is to use Eshell. Run `M-x eshell` to open the shell inside Emacs (on your local machine), then type `cd /ssh:orod-na-thon:path/to/files`. This will transparently ssh to the server and change to the path to your files. The `ls` command will now show the files that exist on the remote server rather than the local computer. You might now expect that there would be an eshell command that you could type to open a remote file in your local Emacs, but there isn’t.

No, in Emacs you always open a file by typing `C-x C-f`. (Unless you rebound it to some other key, in which case make the obvious substitution.)

Any time you hit `C-x C-f` to open a file it defaults to opening files from the working directory of the current buffer. The working directory of the eshell buffer is on the remote server, so the default list of files that you see are all the ones you were already looking at with `ls`. You can start typing a filename and autocomplete will do the rest.

This is an even deeper and more convenient composition of the shell and the editor than having special commands for tasks like opening a remote file in the local editor.

3 comments

> You might now expect that there would be an eshell command that you could type to open a remote file in your local Emacs, but there isn’t. No, in Emacs you always open a file by typing `C-x C-f`

`C-x C-f` calls the `find-file` function which can be called directly from eshell

> You might now expect that there would be an eshell command that you could type to open a remote file in your local Emacs, but there isn’t.

All Emacs Lisp functions are Eshell commands. Say 'find-file <filename>' at Eshell and you're in.

Technically correct, but it is way easier to hit `C-x C-f` just like you would when you are opening a file at any other time. No need for special cases, you just open the file.
`vterm` beats the crap out of `eshell` as a functional terminal, unless you've put a lot of effort into customizing it.

https://www.masteringemacs.org/article/running-shells-in-ema...

That’s because eshell is not a terminal. It’s a shell. You don’t need a terminal to explore the files on the other server.