LanguagesNamedAfterCofee
LanguagesNamedAfterCofee

Reputation: 5952

Bind Escape key in Tmux

Since I have my Caps-lock key mapped to Esc (due to Vim), I'd also like it in tmux.

Specifically, I'm trying to set Esc + a as the prefix:

set -g prefix Escape-a

However, this isn't working, and I get the error bad key: Escape-a. Is this because Esc is not a modifier key? I'd really like this to work, as Esc is on the home row and very convenient to use.

Upvotes: 9

Views: 16712

Answers (3)

datasmurf
datasmurf

Reputation: 181

This sequence:

set-option -g prefix Escape
unbind-key C-b
bind-key Escape send-prefix

...works for me. I'm using tmux-2.0

Upvotes: 18

ivan
ivan

Reputation: 6322

If you're on OS X you can achieve this with karabiner.

In your system preferences, change Caps-lock to Control instead of Esc. Then use karabiner to send Esc when you type Control by itself.

  • karabiner preferences -> "Change Key" tab
  • scroll down to "Change Control_L Key (Left Control)"
  • check "Control_L to Control_L (+ When you type Control_L only, send Escape)"

karabiner preferences

This gives your left pinky easy access to both Esc and Control. You can exit Vim's insert mode the way you already are, and you can set Control+a as your tmux prefix:

set -g prefix C-a

Upvotes: 9

user777337
user777337

Reputation:

I think this is not possible because Esc and a are 2 distinct keys. From what I know tmux doesn't allow key bindings with more than 1 key (for anything).

This is different from having, for example Ctrl-a as a prefix. Even though we type 2 keyboard keys to get it - ^A is represented as a single character by both tmux and vim.

Upvotes: 7

Related Questions