Tmux Tips

I have been an avid Tmux user since 2021, and I don’t know that I could work without it. Tmux is a powerful terminal multiplexer, allowing you to open up mutiple terminals in a single window. My current workflow revolves around using tmux for running processes, sshing into machines, and editing text/code.

I even went as far as to write my own tmux session manager Disconnected that automates the startup of tmux sessions for me by using a json file to craft the tmux session.

Here are five tips that I have discovered over the years.

  1. Change the prefix key to C-a instead of C-b.
set -g prefix C-a
unbind C-b

bind C-a send-prefix

I use a Dactyl Manuform keyboard, so I hit CTRL with my left thumb and can easily hit a with my pinky finger on the left hand. This keybinding makes much more sense to me than C-b as the default. For vim users, the 3rd command is required. C-a is used for incrementing a number on a line, and the command allows this mapping to still work as long as you press C-a twice in quick succession.

  1. Set the base window index to one instead of zero.
set -g base-index 1

On every keyboard that I have used the number row starts with one, and so thus keeping everything on my left hand for the first five windows and then switching to my right hand just makes sense. In my head I am able to map that I need to hit a window on the left half of my tmux sessions or I need to hit the right half and that’s mentally mapped to my hands.

  1. Change the pane selection to vim keybindings. I’m an avid vim user, so another change I made was mapping my pane movement keys to vim movement bindings. This just keeps my mapping the same as I have it in vim so I don’t need to think about it when I need to move panes.
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
  1. Copy commands I often find myself needing to copy pieces of text out of the terminal so this allows me to navigate around the terminal output with C-[ and then I can visually select text with v, and press y to yank (copy) the text into my system clipboard.
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi y send -X copy-selection

I hope these tips have been helpful! They’ve definitely made my tmux experience better.