Skip to main content
2 of 3
added 260 characters in body

How to split the window that ran the "tmux split-window" command instead of the current one?

For example, if I run from window 0:

sleep 2;tmux split-window -h 

and switch to another window 1 with prefix-n before the sleep is over, the window split happens on the new window 1.

How to make the split always happen on window 0 when the command is run from window 0, regardless of the current window?

I have found this possibility:

win="$(tmux display-message -p '#I')";sleep 2;tmux split-window -h -t "$win"

based on: https://superuser.com/questions/385472/get-current-window-number-for-bash-prompt but I don't like it forces me to run an extra command before sleep 2 (which is a real useful command that takes a long time to finish in my use case), which is cumbersome.

Tested on tmux 2.5.