After recently discovering tmux and Tmuxinator, I've been trying to set up a development environment to use.
Per protocol, we aren't allowed to store passwords/passphrases in scripts. So what I'm looking for is a wait for tmux to wait for the SSH tunnel to get set up (password supplied, enter pressed, and logged in).
I know that there's a "wait-for" command in tmux 1.8+. I'm running 1.9a via Cygwin. But even though I've read over the documentation, I'm just having a difficult time understanding it.
tmux new-session -s development -n editor -d
tmux split-window -v
tmux split-window -v
"Need to send to all panes.
tmux send-keys -t development 'ssh user@example.com' C-m
So, here's a very simple version of what I have.
Thoughts? I know I can synchronize-sessions, I'm still working out the kinks in this.
Edit:
Looking into commands, and pulling variables from the pane to the command from synchronized-panes. This might be a "better" way to go about, until I can figure out how to get TMUX to prompt me for user-input.
Might issue a feature request.
Best Answer
Some notes of
wait-for
So the basic usage of wait-for isn't too complicated if you think of it as analogous to threading concurrency primitives
It's not really connected to other tmux functionality, just a convenient implementation of IPC.
wait-for event_name
is like waiting for an eventwait-for -S event_name
is a means of signalling an eventThe
-U
and-L
options are kind of orthogonal and act like semaphoresAddressing your question directly
You can solve these sorts of race condition with
wait-for
but only if commands are synchronous.The problem that you have here is that ssh command isn't synchronous: you can't tell when it has finished.
Looking through the manual we can find the
LocalCommand
directive which seems to do what we want: run a command locally after the connection has finished so we can call