Making TMUX use Alt+Num to select window

Solution 1:

Switching windows with Alt can be done by adding:

# switch windows alt+number
bind-key -n M-1 select-window -t 1
bind-key -n M-2 select-window -t 2
bind-key -n M-3 select-window -t 3
bind-key -n M-4 select-window -t 4
bind-key -n M-5 select-window -t 5
bind-key -n M-6 select-window -t 6
bind-key -n M-7 select-window -t 7
bind-key -n M-8 select-window -t 8
bind-key -n M-9 select-window -t 9

to your ~/.tmux.conf This is from: https://github.com/proft/dotfiles/blob/master/.tmux.conf

Further more, to make it not do this if irssi is in the active window:

#switch windows alt+number, unless we are running irssi
bind -n M-1 if 'test `tmux list-panes -F "#W"` != "irssi"' 'select-window -t 1' 'send M-1'
bind -n M-2 if 'test `tmux list-panes -F "#W"` != "irssi"' 'select-window -t 2' 'send M-2'
bind -n M-3 if 'test `tmux list-panes -F "#W"` != "irssi"' 'select-window -t 3' 'send M-3'
bind -n M-4 if 'test `tmux list-panes -F "#W"` != "irssi"' 'select-window -t 4' 'send M-4'
bind -n M-5 if 'test `tmux list-panes -F "#W"` != "irssi"' 'select-window -t 5' 'send M-5'
bind -n M-6 if 'test `tmux list-panes -F "#W"` != "irssi"' 'select-window -t 6' 'send M-6'
bind -n M-7 if 'test `tmux list-panes -F "#W"` != "irssi"' 'select-window -t 7' 'send M-7'
bind -n M-8 if 'test `tmux list-panes -F "#W"` != "irssi"' 'select-window -t 8' 'send M-8'
bind -n M-9 if 'test `tmux list-panes -F "#W"` != "irssi"' 'select-window -t 9' 'send M-9'
bind -n M-0 if 'test `tmux list-panes -F "#W"` != "irssi"' 'select-window -t 0' 'send M-0'

Which roughly reads Bind key [without requiring prefix], to the action of: check if current pane is not named irssi, and if isn't then select the appropriate window, otherwise, resend the key, so that the underlying application [irssi] can can get it.