Let's say I have a tmux window with 3 panes, on each a terminal on a different machine, and I want to configure their IP address like:

`$ ifconfig eth0 192.168.0.<pane_number>

I normally synchronize panes to write on all of them at the same time, so I'd like to press some key combination and would then insert the specific pane number on each pane (would insert 0 on pane 0, 1 on pane 1...)

Is there such thing available?

1 Answer 1


There is probably a simpler method, but this works. Put in your ~/.tmux.conf, eg

bind-key m run-shell 'v=#D; tmux send-keys ${v#%}'

Then typing C-b m should insert the pane number. #D is replaced by %0 for pane 0 and so on. ${v#%} is to remove the % part, assuming the bash shell. To bind to a key without needing the C-b, eg to C-o, use bind-key -n C-o ....

To have a different number in each pane when synchronised, you will have to temporarily switch sync off, send a char to each pane, and restore sync. Here's a bash script, say mytmux you can put in your PATH and call from your ~/.tmuxrc.

# tmux helper.  http://unix.stackexchange.com/a/325816/119298
if [[ $(tmux show-window-option synchronize-panes) == *on ]]
then    tmux set-window-option -q synchronize-panes off
        restore="tmux set-window-option -q synchronize-panes on"
tmux list-panes -F  '#{window_index} #{pane_index}' |
while read winid pane
do    tmux send-keys -t $winid.$pane $pane

You can then set up a binding for C-b n in your configuration:

bind-key n run-shell "mytmux" 
  • Tried it, but it inserts the pane number of the active pane on all panes. I refined the question, I would want each pane to get its own pane number inserted
    – Chirlo
    Commented Nov 28, 2016 at 8:30
  • I added a bash script to do the individual panes.
    – meuh
    Commented Nov 30, 2016 at 20:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .