I want to have a pane with asciinema "video" (literally it's animated plain text) playing while in another pane the user can be doing miscellaneous stuff (typing commands, writing scripts, or whatever). The user can switch to the asciinema pane and hit < space > key to pause/play the video. I'd like to watch that pane and when the user pauses/plays the recording to then run tmux send-keys to pause/play an mp3 file that's playing in cmus in another window.

I haven't been able to find anything like tmux watch-pane or tmux listen. Does something like that exist? For this use case it'd need to distinguish between spaces being entered via asciinema and actual button presses by the user.

I'm using tmux 2.1, and don't see anything about watch or listen in the man page. But maybe in a newer version there are commands provided?


There are a few ways you could try to do this, of varying complexity:

  • You could bind the Space key in the root table to do what you want if pressed in the pane you want, perhaps something like:

    bind -n Space if -F '#{m:*asciinema*:#{pane_current_command}}' 'send -t:mycmuswindow Space; send Space' 'send Space'

    Or pane_title or whatever if pane_current_command won't work.

  • You could turn on monitor-silence in the asciinema pane and use the alert-silence hook to similarly send a Space to the cmus pane.

  • You could write a script that uses control mode to listen to data from the asciinema pane and send the Space, this is assuming it prints something you can recognise (like "paused") into the pane you can look for.

  • If using bind on the Space key like that... that code would get evaluated everytime the space key is pressed? Would that be a performance issue or waste system resources? Would it interfere with vim's leader key being mapped to Space? – alec Feb 27 '20 at 18:00
  • in 'send -t:mycmuswindow Space; send Space' 'send Space' is that final 'send Space' redundant? I want to change what keys are sent and I'm confused about that syntax. – alec Feb 27 '20 at 18:02
  • I'm also confused by this syntax '#{m:*asciinema*:#{pane_current_command}}' – alec Feb 27 '20 at 18:24
  • The redundancy of "Space" being repeated three times in 'send -t:mycmuswindow Space; send Space' 'send Space' and two of those times prefaced by "send" confuses me. Would you mind explaining that syntax please? I'm having a hard time finding any explanations of any of that syntax (including the logic) when searching the web for info. – alec Feb 27 '20 at 18:58
  • Unless you have a very slow computer you should not notice any performance problems. You need to send two spaces - one to the cmus window to pause it and one to the current window to pause asciinema. Format syntax is in the man page and also github.com/tmux/tmux/wiki/Formats, m: is matching. if is if-shell which has three arguments, the condition and a true and false command. See man.openbsd.org/tmux#if-shell. – Nicholas Marriott Feb 27 '20 at 19:49

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.