Though if I'm exploring a server problem, it's useful to know how to use vim. If Emacs IS installed, it's probably with default settings and it's easy to forget that it'll scatter auto saves everywhere by default. Especially (and usually only) when I'm behind a machine that doesn't have by Emacs set up.
https://github.com/dustinfreeman/dustinfreeman.emacs.d/blob/...
Format is C-x C-f /gcssh:compute-instance-name:/path/on/remote/machine/filename.txt
To that, I usually bring up tramp and say, who cares you just ssh in from emacs.
I've never understood this argument unless you're coming at it from a sysadmin perspective. Sure if its available everywhere that helps when I'm sshing in to random systems to sysadmin stuff.
But I don't do my development by logging in to random new systems all the time. I do my development in an environment that I have set up to be productive with.
If you’re, for example, a developer working on an embedded platform which (even temporarily) has no ssh, and probably no emacs as well, tramp-mode won’t work.
I’m a hard emacser, but it’s true that vi is usually much more ubiquitously available, so it’s good to know how to use it.
Again, I'm saying that as someone who uses tramp-mode all the time, otherwise.
Maybe I'm wrong but I really don't think embedded developers do a lot of work directly on platforms that low level/limited.
You do your development on your main machine, automate deployment to your target, and debug using a gdb server or openocd.
Honestly mg or nano is more ubiquitous than vi. Any system that has vi installed will likely have nano as well.
nano is a very young editor, comparably, invented in 1999, and GPL on top of that. I'm not sure it even come out of the box with any of the BSDs (OpenBSD at least does not seem to have it).
vi was first written by Bill Joy himself in 1976, and I'm pretty sure it proliferated in many different forms over many, many different platforms.
mg, I don't know!
At one of the Lisp projects I worked on, this split was clearly visible. One of my co-workers had the dev perspective, the other had the sysadmin view. Both used Emacs and Slime, but one had it fully customized, and other had it bare-bones, and spent most of his time in raw terminal anyway.
(I, of course, am hard down on developer view. My Emacs config has no peers :)).
On my last project, I decided to do all remote server ops through Tramp, just to see how convenient it was. Turns out, very.
Besides launching a shell, one trick that you can do is piping Tramp invocation, including across different protocols - essentially creating tunnels. One special case I use frequently is for sudo operations.
C-x C-f, then /ssh:[email protected]|sudo:example.com:/etc/someconfig
Suddenly, you're editing as if you launched a session with sudo on the end machine.
Coupled with dired and M-x shell, it becomes a very convenient way of working.
(And in case Tramp causes you trouble, or you just need to close remote buffers and connections, remember about M-x tramp-cleanup-* set of commands.)
EDIT:
And lest I forget - GDB integration works over Tramp too.
Question: I often find tramp to be significantly laggy and much slower when compared to simply sshing into the remote host. It is almost as if tramp is opening up a new ssh connection for every command. What do people here do about tramp lagginess? I've researched this problem but I have not found a good solution.
Host *
ControlMaster auto
ControlPath /tmp/ssh-%r@%h:%p
This helped me quite a lot with tramp
ControlMaster auto
ControlPath ~/.ssh/cm_socket/%r@%h:%p
ServerAliveInterval 60
Is there something beyond that I should be doing? Does tramp need to be configured in some special way to take advantage of the persistent connection?
FYI: You can set it up to use the container names:
M-x customize-variable docker-tramp-use-names
- edit over tramp - dired over tramp - magit over tramp - build over tramp
Just Beautiful.
It worked okay, only issue i had is that periodic autosave makes the whole emacs freeze due to network round-trip. Disabling/toggling autosave or lenthening the autosave timeout solved solves the issue.
BTW, tramp is really awesome. One of those pearls within GNU Emacs.
Tramp actually does something more clever than an scp too, so it even works on servers that don't support scp.
CTRL-X CTRL-F then => /ssh:[email protected]:~/somefile.txt
and you get a local buffer with the contents of the remote file (via scp). All your editing is the same as if it is local. When you save it does a scp back to the remote machine. You can even edit in docker containers:
/docker:root@03f5f926f1ca:/etc/environment
as if they are local. Merges/diffs all just work its really great.