How to Change tmux Meta Key to a Better One
The tmux tool, or the terminal multiplexer, is great for allowing you to run multiple terminals side by side. What’s even better is that you can somewhat customize its behavior using the tmux.conf file. The meta key is the prefix you press before you issue a command that controls tmux so you can, for instance, split the terminal in two. By default it is set to CTRL-B, and this is how you can change that.
First create the tmux.conf file in your home directory
This will open the vi text editor where you can enter the contents of the file. To change the prefix to CTRL-Y, for example, you would enter this:
Then save the vi file by pressing Esc and typing :wq
As you can see the unbind C-b option tells tmux to rescind the default keyboard shortcut, and the set-option -g prefix C-y tells it to set a new one as the prefix, which is CTRL-Y. So if you have a different shortcut in mind just replace C-y with something else, like C-Space for CTRL-Space, which might actually be a great option. If you want to bind the windows key you could try Super_L.
If you’re not sure which key codes represent which keys on your keyboard you might want to run xev and then press the desired keys to get their codes. The caveat is that for xev to work you’ll need to have X installed and running, which will be the case on any desktop Linux system.
See Also
- tmux – terminal multiplexer
- How To: getting started with tmux
The tmux tool, or the terminal multiplexer, is great for allowing you to run multiple terminals side by side. What’s even better is that you can somewhat customize its behavior using the tmux.conf file. The meta key is the prefix you press before you issue a command that controls tmux so you can, for instance, split the terminal in two. By default it is set to CTRL-B, and this is how you can change that.
First create the tmux.conf file in your home directory
This will open the vi text editor where you can enter the contents of the file. To change the prefix to CTRL-Y, for example, you would enter this:
Then save the vi file by pressing Esc and typing :wq
As you can see the unbind C-b option tells tmux to rescind the default keyboard shortcut, and the set-option -g prefix C-y tells it to set a new one as the prefix, which is CTRL-Y. So if you have a different shortcut in mind just replace C-y with something else, like C-Space for CTRL-Space, which might actually be a great option. If you want to bind the windows key you could try Super_L.
If you’re not sure which key codes represent which keys on your keyboard you might want to run xev and then press the desired keys to get their codes. The caveat is that for xev to work you’ll need to have X installed and running, which will be the case on any desktop Linux system.
See Also
- tmux – terminal multiplexer
- How To: getting started with tmux