6 ms·
You should check out tramp-mode too. Its a killer feature that lets you edit files remotely (AWS, Azure, even docker containers!) as if they are local. All th
by Tistel 8y ago
You should check out tramp-mode too. Its a killer feature that lets you edit files remotely (AWS, Azure, even docker containers!) as if they are local. All the stuff work, so you can do diffs between a local file and an a AWS file and it all appears to be local. If you are editing a remote file and do a git action (through magit) it knows to work on the remote file. You can open up remote shells also. You just go:
CTRL-X CTRL-F then => /ssh:username@example.com:~/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.
- Vekz 8y agoA common selling point for VIM is "its installed everywhere you just ssh in and it's available". To that, I usually bring up tramp and say, who cares you just ssh in from emacs.
- admax88q 8y ago> A common selling point for VIM is "its installed everywhere you just ssh in and it's available". 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.
- anyfoo 8y agoThat’s a very specific development story, though, common to e.g. web development. 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.
- TeMPOraL 8y agoSSH isn't the only protocol supported by Tramp (from what I hear, it's actually a late addition). Essentially, if you can get somehow get a shell on a remote machine, you can make Tramp work with it.
- anyfoo 8y agoIt might be possible to get tramp working over a serial line (while still being able to use the same shell, though?), or over telnet, but practically I'd probably just type "vi" to quickly edit a file. Again, I'm saying that as someone who uses tramp-mode all the time, otherwise.
- admax88q 8y ago> 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. 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.
- anyfoo 8y agoAs an OS developer myself, I can tell you that logging into platforms to quickly tweak something using vi happens all the time. It's not about "directly developing" on the platforms, it's about debugging and trying things out. 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!
- TeMPOraL 8y agoThis really hits at a core of what I call developer vs. sysadmin perspective. A developer usually works in a persistent environment they fully control. A sysadmin does a lot of work on multiple, often short-lived servers. So the former prefers customizing things the way they like; the latter learns and sticks to defaults. 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 :)).
- escapecharacter 8y agoI use /gcssh: with tramp to access files on my Google Cloud machines. It's great. Snippet here: https://github.com/dustinfreeman/dustinfreeman.emacs.d/blob/master/init.el#L50 https://github.com/dustinfreeman/dustinfreeman.emacs.d/blob/... Format is C-x C-f /gcssh:compute-instance-name:/path/on/remote/machine/filename.txt
- jwdunne 8y agoYou can also spawn a shell, provided your particular shell is available, in another window too. I can stay entirely within Emacs if I realise, say, I need to do something en masse that's really easy with a shell one liner. 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.
- lelf 8y agoM-x compile (and related) works too.
- mkettn 8y agotramp supports a great amount of protocols, but only ssh is on active support. I worked in a greater company for a while and used it to access remote files shared via windows file sharing (smb). It worked a long time but then server update came, next smbclient update came and at last tramp update came... hindering me in my workflow for a couple of month.
- julienchastang 8y agoI also recommend helm-tramp for added tramp greatness for example if you regularly access many different hosts/VMs. 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.
- anonacct37 8y agoThe enable ssh mastercontrol and persistent connections.
- julienchastang 8y ago@anonacct37 I've always had 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?
- loskutak 8y agoyou can use ssh controlmaster (adding variation of the following into your .ssh/config): Host * ControlMaster auto ControlPath /tmp/ssh-%r@%h:%p This helped me quite a lot with tramp
- znpy 8y agoI used it on Windows to edit files on a RHEL machine. 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.
- IronBacon 8y agoForget Org mode, forget Tramp, the killer feature is renaming multiple files with Dired! ^__~
- TeMPOraL 8y agoTotally. C-x C-q on a dired buffer, and you can edit most of what's essentially an ls output as if it was a text file. C-c C-c to commit changes. I find myself using it very frequently for file management.
- rcfox 8y agoI had no idea tramp-mode supported docker, that's amazing. FYI: You can set it up to use the container names: M-x customize-variable docker-tramp-use-names
- TeMPOraL 8y agoSeconding the recommendation. 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:username@example.com|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.
- black-tea 8y agoTramp is even more convenient if you set up an ssh config (which you should do anyway). Then you can just open ssh:myserver:somefile Tramp actually does something more clever than an scp too, so it even works on servers that don't support scp.
- kqr 8y agoOh, and do try a dual-pane file manager (like Sunrise Commander) with Tramp. Now the entire world becomes your local file system.