asyncrun.vim icon indicating copy to clipboard operation
asyncrun.vim copied to clipboard

how to pipe local text as stdin of ssh command?

Open pinggit opened this issue 2 years ago • 2 comments

let's say I have a range of text selected, and now I want it to be sent over ssh to a remote machine:

I tried both of these, nothing works:

:'<,'>AsyncRun -save=1 -focus=1 -mode=term ssh remotehost "cat - > myfile"
:'<,'>AsyncRun -save=1 -focus=1 -mode=term echo | ssh remotehost "cat - > myfile"

without AsyncRun using vim native redirect it works:

:'<,'>w !ssh remotehost "cat - > myfile"

pinggit avatar May 15 '22 20:05 pinggit

try to remove -mode=term

skywind3000 avatar Dec 02 '22 05:12 skywind3000

When visually selecting a single line, it won't be sent to the command through AsyncRun for some reason. Probably some parsing magic that is using newline as a delimiter. So either select more than one line (last line always disappears, so no worries there), or do the following, worked for me: :'<,'>AsyncRun -save=1 -focus=1 -mode=term tee | ssh remotehost "cat - > myfile"

nabaco avatar Mar 20 '24 17:03 nabaco