Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bind Escape key in Tmux

Tags:

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.

like image 456
LanguagesNamedAfterCofee Avatar asked Jul 12 '14 02:07

LanguagesNamedAfterCofee


2 Answers

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

like image 114
datasmurf Avatar answered Sep 20 '22 13:09

datasmurf


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
like image 43
ivan Avatar answered Sep 19 '22 13:09

ivan