I use ssh to remotely login to a machine where I subsequently work primarily from Vim. Sometimes I want to run some shell command on my original machine without leaving Vim. What is a non-disruptive way to do this that can make decisions based on something in the remote server?

For example, I might highlight a URL from Vim on the remote terminal, and then want to launch a browser on my local machine that navigates to this website. It shouldn't matter, but I am using cygwin from a Windows 7 PC.

I have never used tmux, but I was thinking maybe it would help facilitate this?

  • Take a look at man screen – Eugen Rieck Mar 4 '15 at 1:23
  • @EugenRieck tmux is an alternative to screen. I think if I start using screen or tmux, I would prefer tmux if it can do what I need. Most people seem to prefer tmux. Can you confirm screen can actually be used for this? I don't have it installed yet, I just recently installed tmux though. – still_dreaming_1 Mar 4 '15 at 1:29
  • Screen can do this and much more. Start screen, then Ctl-A C to create a second window, from which you start your ssh. With Ctrl-A N you can now toggle between the local and the remote window in the same terminal – Eugen Rieck Mar 4 '15 at 1:38
  • @EugenRieck Ok, but could you send a command back to the local window based on text displayed in the remote window, such as a URL? – still_dreaming_1 Mar 4 '15 at 1:40
  • I typically use primary clipboard for that – Eugen Rieck Mar 4 '15 at 1:51

You could use the remote vim to make a ssh back to the local machine. You can setup the public key (this guide is specific for windows/cygwin) so you wouldn't be prompt to enter the password.

Clearly it won't run on the original terminal, but for your example case it doesn't seems to be a problem.

As you are running in windows you would probably need to install a ssh daemon; this link provides some options.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.