skywind3000 / asyncrun.vim

:rocket: Run Async Shell Commands in Vim 8.0 / NeoVim and Output to the Quickfix Window !!
https://www.vim.org/scripts/script.php?script_id=5431
MIT License
1.84k stars 109 forks source link

how to pipe local text as stdin of ssh command? #247

Open pinggit opened 2 years ago

pinggit commented 2 years ago

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"

skywind3000 commented 1 year ago

try to remove -mode=term

nabaco commented 5 months ago

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"