I do something like this with WezTerm. When I ssh into a server where I work, I can run
e some/path/whatever
which just prints a special string containing some control characters, the server hostname and the path. The local wezterm parses it and calls emacsclient with the appropriate TRAMP path. So ssh to server, work there, call `e ~/.bashrc` and the remote file immediately opens in my local emacs.
This is really useful when I am in some deep directory structure.
I use the same mechanism to play remote videos - running `mpv experiment/output_foobar.mp4` just prints the special string, which the WezTerm terminal emulator parses and plays the video using my laptop mpv video player. Really really useful for me every day. I run some experiments, can inspect the results immediately. I also have the "reverse scp" which I use from time to time. `rscp foobar.py /tmp/` causes my laptop to download the foobar.py from the current working directory on the remote server into local /tmp/.
The mechanism is explained here [1] and here [2]
The bash function `e` on the server just prints the special string to SetUserVar with name remotemacs and value hostname---path. In wezterm config I have:
wezterm.on('user-var-changed',
function(win, pane, name, value)
if name == "remotemacs" then
-- remotemacs:hostname---path
local match_start, match_end, hostname, path = string.find(value, "^(.-)[-][-][-](.-)$")
local tramp_path = "/ssh:" .. hostname .. ":" .. path
wezterm.background_child_process {'sh', '/home/loskutak/scripts/remotemacs', tramp_path}
I was actually looking for something like this 2-3 months ago. Did not find anything and was considering writing my own, but got distracted. Quite cool, I encounter situations where I would like to do this all the time.
Sure, but that makes all the difference. I often work on an embedded remote machine with quite restricted vim (can't use a custom config, particularly no language packages). When I am on the remote machine (typically I have to run local commands), I often discover I have to edit a python file (typically just minor edits). So to use vim sftp://host/path/to/file I have to open a new terminal copy the path and then open using sftp. For me that interrupts enough of the workflow, that I just don't bother and instead just edit the file on the remote machine using the restricted vim.
Can you install bcvi on that remote machine? (Genuine question - when I've been in similar situations, it also would have been a no-go to install a binary.
It depends, compiled binaries, no. If it's a shell script yes. Python or Perl maybe. But I agree ideally it would work by transferring a script (or aliases ...) across the ssh link and remove it afterwards.
I'd expect the next generation of terminals to do this out of the box when using SSH.
I never want to run the server's vi[m]/emacs/nano if I already have my own local one completely set up. I don't want to run the remote's bash - I have mine already customized! I want to open a new tab in my terminal - and have it connected to the remote, as if I opened a new tab on the server's terminal.
It's the remote's files and process tree and resources what I want to interact with - but I'd rather leverage my local settings as much as possible.
It's quite fitting as a vim using HAM (with a callsign username), that the top comment on that thread is also a HAM saying how you can also do this in emacs. The world changes all around us, and yet it's always the same.
Sure, but that usually implies that you have a tighter organization. Like you have a specific remote directory that you're mounting. This bcvi thing just lets you visit any directory anywhere on the host and edit a random file, without any mounting discipline.
This is pretty cool. I probably don't have much real use case for it because this is basically how I already do things when I use nfs or sshfs to bring the work to my local machine while keeping the files remote, but with more work involved.
This could use forwarding. Has anybody tried to get that working? I mean, you ssh from host A to B, and from B to C. Then from C you bcvi a file such that you're editing on A.
Nice!
I do something like this with WezTerm. When I ssh into a server where I work, I can run
which just prints a special string containing some control characters, the server hostname and the path. The local wezterm parses it and calls emacsclient with the appropriate TRAMP path. So ssh to server, work there, call `e ~/.bashrc` and the remote file immediately opens in my local emacs. This is really useful when I am in some deep directory structure.I use the same mechanism to play remote videos - running `mpv experiment/output_foobar.mp4` just prints the special string, which the WezTerm terminal emulator parses and plays the video using my laptop mpv video player. Really really useful for me every day. I run some experiments, can inspect the results immediately. I also have the "reverse scp" which I use from time to time. `rscp foobar.py /tmp/` causes my laptop to download the foobar.py from the current working directory on the remote server into local /tmp/.
The mechanism is explained here [1] and here [2]
The bash function `e` on the server just prints the special string to SetUserVar with name remotemacs and value hostname---path. In wezterm config I have:
[1] https://wezterm.org/config/lua/window-events/user-var-change...[2] https://wezterm.org/recipes/passing-data.html
I was actually looking for something like this 2-3 months ago. Did not find anything and was considering writing my own, but got distracted. Quite cool, I encounter situations where I would like to do this all the time.
If I’m reading this right, it’s “open a local vi(m) on a remote file”, by invoking a remote command. Is that right?
I’m wondering how it’s different in effect to just using
Almost, down the page it says:
So it's just a more convenient way to launch local vim, doing something you could do manually.suvi is neat, and bcp seems like something that I'd actually use.
Sure, but that makes all the difference. I often work on an embedded remote machine with quite restricted vim (can't use a custom config, particularly no language packages). When I am on the remote machine (typically I have to run local commands), I often discover I have to edit a python file (typically just minor edits). So to use vim sftp://host/path/to/file I have to open a new terminal copy the path and then open using sftp. For me that interrupts enough of the workflow, that I just don't bother and instead just edit the file on the remote machine using the restricted vim.
Can you install bcvi on that remote machine? (Genuine question - when I've been in similar situations, it also would have been a no-go to install a binary.
It depends, compiled binaries, no. If it's a shell script yes. Python or Perl maybe. But I agree ideally it would work by transferring a script (or aliases ...) across the ssh link and remove it afterwards.
Looks like it's all Perl:
https://github.com/grantm/bcvi
But it's not a single consolidated script.
does sftp require configuration beyond what you've already got working if you're ssh'd in?
I mean you run that command locally. You aren’t ssh’d in, vim copies the file to a tmp location and you edit it, `:w` writes it back to the remote.
Wow, I've been using Vim exclusively as my text editor now for 15 years and I did not know it could do this. Awesome!
Always learning something new with vim. For such a barebones looking editor, it's got a lot going on.
ngl didn't know vim supported that so conveniently
I'd expect the next generation of terminals to do this out of the box when using SSH.
I never want to run the server's vi[m]/emacs/nano if I already have my own local one completely set up. I don't want to run the remote's bash - I have mine already customized! I want to open a new tab in my terminal - and have it connected to the remote, as if I opened a new tab on the server's terminal.
It's the remote's files and process tree and resources what I want to interact with - but I'd rather leverage my local settings as much as possible.
Discussion at the time https://news.ycombinator.com/item?id=1406145
And the top comment is about Emacs. Yep, that's a vi post alright.
One of the reasons Emacs grew a fan base is that it had powerful features nothing else had. Sometimes decades before anyone else.
It's quite fitting as a vim using HAM (with a callsign username), that the top comment on that thread is also a HAM saying how you can also do this in emacs. The world changes all around us, and yet it's always the same.
Hams don't let hams upcase ham. :)
I prefer sshfs for something like this. Then I can create files the regular way and edit files with my local neovim config.
Sure, but that usually implies that you have a tighter organization. Like you have a specific remote directory that you're mounting. This bcvi thing just lets you visit any directory anywhere on the host and edit a random file, without any mounting discipline.
I just mount root of the remote system.
This is pretty cool. I probably don't have much real use case for it because this is basically how I already do things when I use nfs or sshfs to bring the work to my local machine while keeping the files remote, but with more work involved.
This could use forwarding. Has anybody tried to get that working? I mean, you ssh from host A to B, and from B to C. Then from C you bcvi a file such that you're editing on A.
Look at what they need to mimic a fraction of our power (TRAMP)
As a vimmer I whole heartedly agree, there’re aspects of Emacs that’s very hard to argue against, another one is the client server model
[dead]