5 ms·
This comment was posted using tmux scripting, as follows: set -x send(){ tmux send "$@";} send 'links -no-connect https://news.ycombinator.c
by 3xblah 7y ago
This comment was posted using tmux scripting, as follows:
set -x
send(){ tmux send "$@";}
send 'links -no-connect https://news.ycombinator.com/login?goto=news' ;
send c-m; sleep 2;
send 3xblah c-m $HNPASSWORD c-m c-m c-m; sleep 2;
send Escape; sleep 1; send V S; sleep 1;
send 'scripting tmux' c-m Down Down Down Down Down Down c-m;
send Escape; sleep 1; send V S; sleep 1;
send 'add comment' c-m Up;
send 'This comment was posted using tmux scripting, as follows: ' c-m;
a=$(sed '5,18!d' $0); sleep 2;
send "$a"; sleep 2; send c-m c-m Down c-m;
- atq2119 7y agoA tmux/HN quine, or at least something close to it. This deserves to go into some sort of hall of fame.
- GordonS 7y agoNice, 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.
- tyingq 7y agoReplacing the sleeps with calls to "tmux capture-pane" to parse the responses would be closer to expect.
- 3xblah 7y agoBrainless 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.
- abcdef123xyz2 7y agocapture-pane has -p so you can pipe its output rather than letting it create a buffer you have to delete.
- 3xblah 7y agos/has/now &/ I started using tmux in 2009. There was no -p option when capturep command was first added. Old scripts that keep working tend not to get updated. I have updated it now. Thank you.
- hashhar 7y agoIs this an accidental quine? That's so cool. [Quine]: https://en.wikipedia.org/wiki/Quine_%28computing%29 https://en.wikipedia.org/wiki/Quine_%28computing%29