Scripting tmux
arp242.net
arp242.net
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; 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.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.
[Quine]: https://en.wikipedia.org/wiki/Quine_%28computing%29
In the backend, it's all tmux CLI commands.
tmuxp (https://tmuxp.git-pull.com), similar to tmuxinator, uses libtmux under the hood to build workspaces from a yaml/json file: https://github.com/tmux-python/tmuxp/blob/master/tmuxp/works...
Despite that, I've found some people prefer just using plain tmux scripting (https://twitter.com/bitprophet/status/561356905843392514). Aside: That's Jeff Forcier, creator of fabric (http://www.fabfile.org/)
Through tmux's formats (http://man7.org/linux/man-pages/man1/tmux.1.html#FORMATS), you can about any info you'd like on your workspace.
An area I don't know about is -C (control mode). libtmux could technically use it to get live updates rather than inefficiently and possibly needlessly querying session/window/pane info to keep objects up to date. Apparently iterm2's tmux integration uses it.
Anyone know of this or a better approach?
It does require some gyrations to get around the fact that it logs everything (the command itself, terminal control, etc), and not just what's output by the command. Here's a quick and dirty example:
a) Start a tmux session to a remote host
b) On the local host, run this (assuming session 0):
$ tmux pipe-pane -o -t0 "tail -n +2 | col -b | base64 -d > ~/output"
$ tmux send-keys -t0 "base64 /some/file && read" Enter
$ tmux pipe-pane -t0
$ tmux send-keys -t0 Enter
You should now have ~/output on the local host, which is identical to /some/file on the remote.
which-key on vim has been great in making sure, I use new features, I add to my config file.
Not utterly comfortable, but helps most of the time.