tmux - stealing Alt key from Midnight Commander, emacs

2.5k views Asked by At

just starting to use tmux. I really like it so far -- a solid replacement for screen. The one single problem I have is that tmux steals the Alt (meta) key presses from a Midnight Commander running within it.

I have made my prefix key C-[, which works well. But tmux also interprets Alt + anykey the same as C-[ + anykey when using Midnight Commander. Since there are lots of Alt+ keystrokes in MC, this become pretty annoying.

So I either need to have tmux ignore Alt + keystrokes for all applications running within it (e.g., Midnight Commander, emacs, etc).

My .tmux.conf file is shown below. Any help would be greatly appreciated.

Thanks, Madeleine.


# Turn on the status bar and change the coloring to my preference.
# It is handy to highlight in red the active window.
set -g status on
set -g status-bg black
set -g status-fg white
set -g status-left ‘#[fg=green]#H’
set-window-option -g window-status-current-bg red

# Use emacs keys
set -g status-keys emacs

# Makes the prefix key immediately available. There
#  is no pause necessary for an escape sequence
set -s escape-time 0

# Make our prefix key:  [
unbind C-b
set -g prefix C-[

# Split windows using emacs keys
unbind %
bind 2 split-window -v
bind 3 split-window -h

# Allow a mouse click to switch panes
set-option -g mouse-select-pane on

# Set up a key to switch to the last active window
bind-key C-l last-window
1

There are 1 answers

1
chepner On BEST ANSWER

The problem is the Ctrl[ and Alt are two different ways of sending the exact same character (ASCII 33, ESC) to the terminal. There is no way for the terminal to know which physical key(s) generated the character. Since tmux sits between the terminal and Midnight Commander, it will always see the ESC first and consume it. I think your only option is to use a different prefix in tmux.