TMUX: After split-window, how to know the new pane id

tmux

It seems like a simple enough procedure that I'm trying to accomplish, yet I've searched to no avail. I would like to create a key binding which does a split-window and then send-keys to the newly-created pane; however I need the pane id to use with the send-keys command. The catch is that I WILL NOT know how many panes are currently open in the window; thus I know of no way for the code running in the original pane to deduce what the new pane index will be. Is there any way to find out this new index or id (either one can be used as a target)?

Thanks.

Best Answer

You are over-thinking your problem. When you do split-window the new pane becomes the current target for send-keys. You should not be calling tmux in the binding as you are already in tmux. Try

bind-key s split-window \; send-keys "pwd" Enter
Related Question