Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Start Your Tmux Window and Pane Index Count at 1 Instead of 0

blog/cards/start-your-tmux-window-and-pane-index-count-at-1-instead-of-0.jpg

We'll go over how to do the above as well as auto-remove index gaps after closing a window. Your index counts will always be in order.

Quick Jump: Demo Video

Being able to switch windows is typically much easier when your windows are arranged as 1, 2, 3 instead of 0, 1, 2 (the default). This is especially true if your Tmux prefix key is on the left side of your keyboard (mine is with the ` key).

Demo Video

Tmux Configuration

# Start windows and panes index at 1, not 0.
set -g base-index 1
setw -g pane-base-index 1

# Ensure window index numbers get reordered on delete.
set-option -g renumber-windows on

Timestamps

  • 0:09 – Starting off the window index at 1
  • 0:48 – Starting off the pane index at 1
  • 1:20 – Ensuring window index gaps get removed after deleting a window
  • 2:11 – Taking a look at the 3 tmux config options to make all of this work
  • 2:59 – Testing the window index value to start at 2, yep it works

Are you doing this in your config? Let me know below.

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per month (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments