Tmux with non-alphanumeric prefix

tmux

I have tmux 1.5 installed on a couple of Ubuntu machines and I have this in my ~/.tmux.conf:

unbind-key C-b
set-option -g prefix C-\

So, on a couple of RedHat machines I have ssh access to (but not root) I compiled tmux 1.6 and installed it in my directory. Now when I try to set C-\ as my prefix, I get this on startup:

 /home/user/.tmux.conf: 2: line continuation at end of file

Obviously its not parsing the file correctly. As a test I change it to:

unbind-key C-b
set-option -g prefix C-'

And I get:

 /home/user/.tmux.conf: 2: invalid or unknown command: set-option -g prefix C-'

So it's still not parsing correctly.

However, this does work:

unbind-key C-b
set-option -g prefix C-o

So it seems to be a problem with non-alphanumeric keys.

any ideas>

Best Answer

In tmux 1.6 a backslash at the end of a configuration line acts as a line continuation character. You can arrange to get the backslash to the command itself in several ways:

Simply make sure it is not the last character. Put a space after it, or a space and a comment:

set-option -g prefix C-\ # (not a line continuation!)

Wrap it in single quotes:

set-option -g prefix 'C-\'

Wrap it in double quotes (and escape it, since backslash is special inside double quotes):

set-option -g prefix "C-\\"

Your C-' was failing because the single quote was starting a quoted string (the error message is not so helpful here).

Also, there is no standard control character or sequence for Control-', so tmux would have complained (bad key: C-') even if you had double quoted it to get it past the initial parsing stage; there are only a handful of non-alphabetic control characters: @[\]^_?.

Related Question