tmux and i3 are both popular tools used in the Linux world. Tmux is a terminal multiplexer, which means it allows you to run multiple terminal sessions in a single window. On the other hand, i3 is a tiling window manager that helps you manage and organize your windows efficiently. In this article, we will explore how to move tmux panes in a way that emulates the movement in i3.
By default, tmux uses the arrow keys to navigate between panes. However, if you are used to i3's movement keys, you might find it more convenient to use the same keys in tmux as well. To achieve this, we can make use of tmux's key bindings and customize them to match i3's movement keys.
To get started, open your terminal and launch tmux by typing tmux and pressing Enter. Once inside tmux, you can create multiple panes by using the following key combination:
Ctrl + b % - Split the current pane vertically.
Ctrl + b " - Split the current pane horizontally.
Now that we have multiple panes, let's configure the key bindings to emulate i3's movement. To do this, we need to edit tmux's configuration file. Open a new terminal window (outside of tmux) and enter the following command:
vim ~/.tmux.conf
If the file doesn't exist, it will be created. Add the following lines to the file:
# i3-like movement bind -n M-h select-pane -L bind -n M-j select-pane -D bind -n M-k select-pane -U bind -n M-l select-pane -R
Save the file and exit vim. Now, let's explain what these lines do:
bind -n M-h select-pane -L- This line binds the key combinationAlt + hto move the focus to the pane on the left.bind -n M-j select-pane -D- This line binds the key combinationAlt + jto move the focus to the pane below.bind -n M-k select-pane -U- This line binds the key combinationAlt + kto move the focus to the pane above.bind -n M-l select-pane -R- This line binds the key combinationAlt + lto move the focus to the pane on the right.
Feel free to modify these key bindings to match your preferences. Once you have made the changes, save the file and exit.
Now, let's reload the tmux configuration to apply the changes. In the terminal window where you have tmux running, press Ctrl + b : (colon) to enter the command prompt. Type source-file ~/.tmux.conf and press Enter. This will reload the configuration file and apply the new key bindings.
Now you can use the Alt + h, Alt + j, Alt + k, and Alt + l keys to move between tmux panes, just like you would in i3.
It's worth mentioning that you can also customize other aspects of tmux, such as the color scheme, status bar, and many more. If you're interested, you can explore the tmux documentation for more information.
In this article, we learned how to move tmux panes emulating i3 movement. By customizing tmux's key bindings, we were able to use the same movement keys as i3, making it easier for users familiar with i3 to navigate between panes in tmux. Customizing tools to match your preferences can greatly improve your productivity and overall user experience.
References
| Reference | Link |
|---|---|
| tmux | https://github.com/tmux/tmux/wiki |
| i3 | https://i3wm.org/ |