Reputation: 1085
I have a shell script (lets name it a.sh
) where I run a certain command. At some point this command needs user input.
I have setup a vim key binding where I run a.sh
in a tmux session.
function! CreateTmux()
!tmux has-session -t mysession || tmux new-session -d -s mysession
!tmux send-keys -t mysession 'a.sh' Enter
" This should be delayed by a few seconds
!tmux send-keys -t mysession 'my choice' Enter
endfunction
nnoremap <F9> :call CreateTmux()<CR>
I would like to make a delayed send-keys
through tmux to the session to input my choice for the prompt as well. Here is my code.
The limitations:
1. I hope to avoid blocking commands in vim so that I can continue working.
2. I can not edit a.sh so I can't make it pass without the prompt.
3. I don't have vim 8 and can't get it on the server that I am working on.
Upvotes: 2
Views: 1629
Reputation: 12255
You could try running the last tmux line in the background with a shell sleep. Replace the last line of the function with
!(sleep 4 && tmux send-keys -t mysession 'my choice' Enter)&
You would only need the ()
if you want to replace the &&
by ;
for example.
Upvotes: 2