4

I'm using tmux 1.6 with konsole on Fedora 17 i686.

I have an azerty keyboard (with accentued chars), and I want ton bind 'ù' key.

I made the following ~/.tmux.conf:

setw -g utf8 on
bind-key ù split-window -h

But, when I run tmux I have the following error:

/home/glines/.tmux.conf: 2: unknown key: ù

Is there a way to bind this key?

For your help, Thanks by advance.

1
  • The selected answer is outdated. Tmux does support UTF-8 binding now. See the other answer.
    – Florian
    Mar 31, 2020 at 20:09

2 Answers 2

7

Unfortunately, tmux only supports single 8-bit values in its key bindings.

If you were using a (fixed length) 8-bit encoding (e.g. ISO 8859-1, ISO 8859-15, etc.), then the binding should have worked. If you are using UTF-8, however, your ù (U+00F9) is encoded as two bytes (C3 B9), and tmux rejects it as a unknown key name (if a key is longer than a single byte (after stripping its modifier prefixes), it is processed as the name of a special key e.g. F1, PageUp, KP0, etc.).


Though, if you are desperate there is a gross hack that you could try:

tmux bind-key -r $(printf '\303') display 'c3 prefix binding hack' \; \
     bind-key -r $(printf '\271') split-window -h

This abuses the “repeat” binding functionality by using it to stay in “prefix mode” while basically ignoring the first byte of the UTF-8 encoding of ù (hex C3 B9, octal 303 271).

The first byte of ù (octal 303) is bound to a dummy command, and the second byte (octal 271) is bound to the target command. This requires that you must not have set the tmux repeat-time option to zero (to disable repeating), and has a side effect of leaving tmux in its repeat mode for repeat-time milliseconds (defaults to 500ms) after you have typed Prefixù (this side effect will usually only be noticeable if you immediately type an arrow key (with or without Control or Meta) after Prefixù—those keys are the only default bindings that are “repeatable”).

The above example uses the printf shell command to generate the required bytes, but this will not work in your .tmux.conf. If you were running tmux 1.7, you could write it like this (in your .tmux.conf):

bind-key -r 0xC3 display 'c3 prefix binding hack'
bind-key -r 0xB9 split-window -h

However, this hex key syntax does not work in tmux 1.6. So, you either need to arrange for the raw bytes to be directly in the file (your text editor may fight you on this, and it is easy to make a mistake), or use a shell to assist you:

run-shell "tmux bind-key -r $(printf '\\303') display 'c3 prefix binding hack' \\; bind-key -r $(printf '\\271') split-window -h"

Note: run-shell runs its command asynchronously, so the bindings may not be available immediately after your first session starts.

3
  • Thanks for your answer, the run-shell part doesn't work but I will update tmux soon.
    – GlinesMome
    Dec 12, 2012 at 7:07
  • The problem with the run-shell command may have been that I used ~/bin/tmux instead of plain tmux (I have edited the answer; I also dug up a 1.6 binary and verified that it worked with it in a separate server instance). Dec 12, 2012 at 7:57
  • So what is the syntax if I want to bind split-window -h on <kbd>Prefix</kbd>, <kbd>Control</kbd>+<kbd>ù</kbd>?
    – fauve
    Feb 29, 2016 at 0:50
3

Since tmux 2.3 dynamic rebinding as explained by Chris Johnsen is no longer necassary and does not even work. To bind any UTF-8 character just use it's unicode value in 0x notation.

Example

Let's say you want to bind Prefixě (small E with caron) to window 2.

First you need to find out unicode value of ě (note that this is defferent from UTF-8 code sequence).

You can use e.g. python3 to convert UTF-8 character to it's unicode value:

$ python3
>>> hex(ord('ě'))
'0x11b'

Now when you know unicode value of ě is 0x011B simply add this line to your tmux config file:

bind-key 0x011B select-window -t 2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .