DEV Community

Aleksey Reprintsev
Aleksey Reprintsev

Posted on • Updated on

My favorite tmux prefix

For a long time I used screen, but now tmux is my favorite terminal multiplexer. But my fingers could not get used to the Ctrl+b combination, so I decided to please them. An internet search revealed that the most popular prefix combinations are Ctrl+a, Ctrl+Space, Backtic, CapsLock followed by many others.

My wishes:

  • the keys for the prefix were located side by side;
  • it was not necessary to twist the fingers to press them;
  • there were two symmetrical combinations for the right and left hand.

The most promising combination at first seemed to be Ctrl+Space, and at first it even seemed convenient, but after experimenting I found it.

So my favorites: Alt+z and Ctrl+/

My usual tmux workflow is: open multiple panes, select a layout, switch between panes, expand/collapse a pane, minimize tmux, expand tmux, detach the session.

LAlt+z, LShift+', LAlt+z, LShift+', RCtrl+/, RAlt+2, LAlt+z z, LAlt+z z , LAlt+πŸ •, LAlt+πŸ —, LAlt+z RCtrl+z, fg, RCtrl+z d

Almost like playing the piano :)

Explanation:
(LAlt - left Alt key, LShift - left Shift key, RCtrl - right Ctrl key, RAlt - right Alt key)

  • LAlt+z, LShift+' # Split the current pane into two, top and bottom
  • LAlt+z, LShift+' # Split the current pane into two, top and bottom
  • RCtrl+/, RAlt+2 # Arrange panes even-vertical
  • LAlt+z z # Zoom current pane
  • LAlt+z z # Unzoom current pane
  • LAlt+πŸ • # Switch to pane above
  • LAlt+πŸ — # Switch to pane below
  • LAlt+z RCtrl+z # Suspend theΒ tmuxΒ client
  • fg # Bring tmux to foreground (bash command)
  • RCtrl+/ d # Detach the current client

Here is my config file

# reload config after changes
# tmux source-file ~/.tmux.conf

# colors
set -g default-terminal "screen-256color"
# set -g default-terminal "tmux-256color"

# prefix keys
unbind C-b
set-option -g prefix C-_                # Ctrl+/
set-option -g prefix2 M-z
bind-key C-_ send-prefix
bind-key M-z send-prefix -2

# mouse mode on
set-option -g mouse on

# key bindings
bind r source-file ~/.tmux.conf         # reload config

# switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
Enter fullscreen mode Exit fullscreen mode

I hope this proves useful to someone.

Top comments (0)