2

I am trying to send a message to a running tmux window that is side by side, to tell it to run a script when I press a button. What I am trying to do is done by doing:

silent !tmux send -t 0.1 ruby test.rb ENTER 

Which will silently run the script. However, the display goes blank or glitches whenever I run this, and I than need to run the redraw! command to display the buffer again.

What would be the best way to convert these commands into a function?

:silent !tmux send -t 0.1 'ruby test.rb ENTER' 
:redraw!

so far I have tried doing the following, but I seem to be messing up somewhere:

silent !tmux send -t 0.1 ruby test.rb ENTER <CR> redraw! <CR> 
silent exec "tmux send -t 0.1 'ruby test.rb ENTER' | redraw!"

Overall, I am wondering what the best way to achieve sending messages to a tmux window would be and if this is a somewhat correct method, what is the proper way to build a vim function peicing that together?

  • I'm voting to close this question as off-topic because it appears to be more about tmux than vi/vim. – Herb Wolfe Mar 19 '17 at 1:45
  • @HerbWolfe The phrasing may be a bit off from what I'm trying to say, my bad. I'm more just looking to find out if there's a better way to send an external shell command from within vim and if not, how I can properly format it into a vimscript function. – Jack Mar 19 '17 at 2:05
3

After messing around a bit more and looking over some stuff I was able to get this to work by wrapping the external command and its parameters in an execute command then using the bar to send the redraw command.

:execute  "silent !tmux send -t 0.1 'ruby test.rb' Enter" | :redraw!

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.