Re:Scripting tmux
by 3xblah on Saturday January 04, 2020 @12:32AM
(#21953082)
This comment was posted using tmux scripting, as follows:
[ Parent
| on HN ]
Is this an accidental quine? That's so cool.
[Quine]: https://en.wikipedia.org/wiki/Quine_%28computing%29
A tmux/HN quine, or at least something close to it. This deserves to go into some sort of hall of fame.
Nice, I had no idea you could script tmux like that! Reminds me of "expect", which I've used to automate interactive SSH sessions with network devices.
Replacing the sleeps with calls to "tmux capture-pane" to parse the responses would be closer to expect.
Brainless method I use to check the panel:
case $1 in
""|-b|-E|-S|-t)
tmux capturep $@ --;
tmux showb $@ --;
exec tmux dele --;
esac
Also there is a "-N repeat count" option for send-keys in newer versions of tmux.
Re:Scripting tmux
by abcdef123xyz2 on Sunday January 05, 2020 @03:26PM
(#21963802)
capture-pane has -p so you can pipe its output rather than letting it create a buffer you have to delete.