Changing tmux prefix to a single key

Replacing the default Ctrl-B prefix in tmux is what the majority of new tmux users does as a first step. Most often it is replaced with Ctrl-A. But that still is a combination of two keys. Here is a simple trick how we use a single Modifier Key as prefix.

When I started to use tmux a couple of weeks ago I quickly realized that I had to change the prefix key in order to use it efficiently. However using Ctrl-A instead of Ctrl-B only seems to be a small improvement. I wanted to change it to a single key instead. There is no way to do that in tmux directly but remaping a modifier key to Ctrl-B does the trick.

I decided to use the Menu key as prefix as I never used that key and I can reach it with my little finger without moving away my entire hand from the home row. The Menu key is something I never used and that seems to make it a perfect fit.

xcape -e 'Menu=Control_L|B' 

Commands in my tmux.conf are organized in a way that the ones I use most often can be reached without moving my left hand away from the home row.

bind a split-window -h
bind q split-window -v
bind e select-pane -U
bind d select-pane -D
bind s select-pane -L
bind f select-pane -R
bind g new-window 
bind r next-window
bind w previous-window

Unfortunately xcape sends the key combination only when the key is released. So there is still a need to press and release the Menu key rather than using it as a real modifier key. That allows for another technique to be applied. We can set a timeout. That made me try some experiments with using my left shift key as prefix.

Setting the timeout to 100 ms means that we can send the Ctrl-B if we press Shift and release it within 100ms and use it as normal Modifier key when we exceed that timeout.

xcape -e 'Shift_R=Control_L|B' -t 100

Thinking about those kind of optimzations may seem to be a waste of time for the majority of people. But if that change only saves us 0.5 second per execution and we use it 50 times a day this sums up to 2.5 hours a year and an entire day in 10 years. So it is well worth investing some time for optimization.

Contact