Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking to send commands to a separate tmux pane from vim and I figured the easiest way was to mkfifo a named pipe /tmp/cmds and run bash < /tmp/cmds to listen for commands to run.

I then do echo "echo \"hello world\" > /tmp/cmds" as test, this only works for one command and xargs closes immediately. Is there any way to keep this running after more than one command?

share|improve this question
up vote 1 down vote accepted

this is no different from running xargs on the interactive shell and terminate with a newline, so it will finish and exit.

you would have to write a loop and execute for each line of input from stdin such as

while :; do xargs < /tmp/cmds; done

not tested so you may need to tweak.

share|improve this answer

If anyone was wondering, here's the script I use for sending commands from vim:

mkfifo $FIFO &> /dev/null
while :; do bash < $FIFO && echo "== OK ==" || echo "!! ERR !!"; done

Here's a vim function to send commands to this pipe:

function! RCmd(cmd)
  :silent! exe '!echo "cd ' . getcwd() . ' && ' . a:cmd . '" > /tmp/cmds'

A mapping that sends make to the window on <F4>

map <F4> :call RCmd("make")<CR>

Have fun!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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