tmux swap-window command behaves differently on local and remote sessions

48 views
Skip to first unread message

eggbean

unread,
Jun 23, 2021, 8:57:35 PM6/23/21
to tmux-users
I have been using these settings for many years (around 12 years) on remote SSH sessions without any problems. 

# Window navigation
bind -n C-PPage prev
bind -n C-NPage next
bind -n C-S-PPage swap-window -t -1
bind -n C-S-NPage swap-window -t +1

But I have started using Linux as desktop OS relatively recently, and so I have had this problem for a couple of years, but thought I would eventually figure out what the problem is, but I still have not:

PROBLEM: The second two settings, to move the windows in the statusbar work fine on remote SSH sessions, but when tmux is used locally, they don't. The windows get swapped as expected, but the other window becomes the current one, instead of the one that was current when the swap was initiated.

Why does this happen?

I am using Pop!_OS 20.04, which is based on Ubuntu and Alacritty as the terminal emulator, although this behaviour seems to work on any terminal.

Thanks for any help that can be provided.

Scott Rochford

unread,
Jun 24, 2021, 12:51:04 AM6/24/21
to eggbean, tmux-users
Are the the tmux versions (tmux -V) the same?

Regards
Scott

--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/tmux-users/41a14582-ff8e-4a78-aab1-f8f21b4ada25n%40googlegroups.com.

eggbean

unread,
Jun 24, 2021, 3:06:32 AM6/24/21
to tmux-users
No. I have found that it was a still undocumented change made in v3.0.  


I have done this to get around it, as I use different versions of tmux and the same .tmux.config:

# Find and set tmux version
run-shell 'tmux setenv -g TMUX_VERSION $(tmux -V | \
    sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
...
# Move window on statusbar
if-shell -b '[ "$(echo "$TMUX_VERSION < 3.0" | bc)" = 1 ]' " \
    bind -n C-S-PPage swap-window -t :-1; \
    bind -n C-S-NPage swap-window -t :+1"
if-shell -b '[ "$(echo "$TMUX_VERSION >= 3.0" | bc)" = 1 ]' " \
    bind -n C-S-PPage swap-window -d -t :-1; \
    bind -n C-S-NPage swap-window -d -t :+1"

Seems to be working well so far.

Cheers

eggbean

unread,
Jul 10, 2021, 6:49:33 PM7/10/21
to tmux-users
The solution above works, but only after I use the keyboard shortcut that I have set to reload the configuration. At some point it stops working again, as when I find myself trying to shift a window on the statusbar again, I have to reload the configuration again.

I have only noticed this on my laptop (not other hosts that I remote into), which just happens to be the only system that I am using that uses a > v3.0 tmux.

Does anybody know why it seems to be losing this setting, or have any ideas on how to troubleshoot it?

eggbean

unread,
Jul 27, 2021, 9:12:39 AM7/27/21
to tmux-users
I have got a bit further in figuring out what is going on. It seems that the settings get changed when I use a nested tmux that uses a different version. I use this (but modified) config for nested tmux:
http://stahlke.org/dan/tmux-nested/

So to make this work I think I will have to add those lines to this nesting part of the config as well, which is going to make my already complicated looking tmux config much more complicated. urgh
Reply all
Reply to author
Forward
0 new messages