Bind Ctrl+Tab and Ctrl+Shift+Tab in tmux
Recent “unreleased” versions of tmux do automatically recognize those xterm-style key sequences once you have your terminal sending them (no need to change your terminfo entry). The next release version (1.8?) should also have this support. With an appropriate build of tmux1, all you have to do is bind the keys in your tmux configuration:
bind-key C-Tab next-window
bind-key C-S-Tab previous-window
You will still need to type your prefix key before these keys.
(Note: ~/.tmux.conf
is only processed when the server starts. If you make changes to it, you will either need to exit all your sessions and restart the server, or use (e.g.) tmux source ~/.tmux.conf
to have your existing server re-process the file.)
Also, if you want tmux to pass along these (and other) xterm-style key sequences to programs running inside tmux, then you will need to enable the xterm-keys
window option.
set-option -gw xterm-keys on
(If you prefer, you can do this on a per-window basis by using -w
instead of -gw
.)
If you want to be able to use those keys without typing the prefix, then you can use “no prefix” bindings instead:
bind-key -n C-Tab next-window
bind-key -n C-S-Tab previous-window
This will more or less “dedicate” the keys to tmux, though. It will be difficult to type these keys to any program running inside tmux (e.g. you would have to use the tmux command send-keys C-Tab
—as normal, xterm-keys
must be enabled to send these xterm-style key sequences).
The problem with your terminfo entry editing is probably because each line after the one that names the terminal type needs to start with a Tab. Lines that do not start with a tab are the beginning of a new terminal entry. Technically, the NL TAB sequence is basically a line continuation in this file format; each entry is a single logical line.
Also, if you are redefining terminfo entries, be sure to use -x
with infocmp and tic to preserve the user-defined capabilities (some of which are fairly standard).
1 I.e. built from recent code in the tmux Git repository at sf.net (at the clone-able URL git://git.code.sf.net/p/tmux/tmux-code
).
How to change prefix key of tmux to Ctrl?
As explained in another answer at Unix Stack Exchange, this can't be done:
Ctrl and Shift are modifiers. These keys aren't transmitted to applications running in a terminal. Rather, when you press something like Ctrl+Shift+A, this sends a character or a character sequence at the time you press the A key.
binding the shift key in .tmux.conf doesn't work
You can't and it's not a good idea, the shift key is by no way meant for that. Take a look in the man tmux
, section KEY BINDINGS
for the list of available keys. More info are available here https://unix.stackexchange.com/a/140010
How to use Ctrl-semicolon for prefix in tmux?
Terminal can't register a Ctrl-;
keystroke. It's just not a valid character. If you look at the control characters in the below ascii table, you'll see Ctrl-;
is not on the list.
I'm on OS X and when I type Ctrl - ;
in the (terminal and in a "desktop" program) I get a bell sound indicating the character is not recognized or something.
As for the "favorite" prefix key: from what I saw reading other people's .tmux.conf
files, Ctrl-a
is the most popular choice. This makes sense because:
Ctrl-a
was the default for GNU Screen, tmux predecessor- it's much easier to type than the default
Ctrl-b
especially when you remap caps lock to ctrl.
The downside to using Ctrl-a
is that you can't use the same key in bash or vim, but that's easily solved by having the following binding in .tmux.conf
:
bind-key 'C-a' send-prefix
With that, pressing the Ctrl-a
twice will send the same character to the underlying program (eg bash or vim).
Related Topics
The Concept of 'Hold Space' and 'Pattern Space' in Sed
Differencebetween Double-Ampersand (&&) and Semicolon (;) in Linux Bash
How to Run Crontab Job Every Week on Sunday
Generating a Sha-256 Hash from the Linux Command Line
Don't Fail Jenkins Build If Execute Shell Fails
Negate If Condition in Bash Script
Creating Temporary Files in Bash
How Pthread_Mutex_Lock Is Implemented
How Find Out Which Process Is Using a File in Linux
How to Kill All Linux Processes That Are Older Than a Certain Age
How to Fix Conda Update Conda Permission Error
Replace Whitespace with a Comma in a Text File in Linux
What's the Purpose of Each of the Different Uids a Process Can Have