Post
Setting Up `tmux` for a Better Terminal Workflow
If you spend a lot of time in the terminal, tmux is one of the simplest tools you can add to improve your workflow. It lets you keep multiple terminal sessions open, split your screen into panes, detach from running work, and reconnect later without losing state.
What tmux gives you
With tmux, you can:
- keep long-running processes alive
- split one terminal window into multiple panes
- switch between named sessions
- reconnect to your work after SSH disconnects
- manage several projects without opening a dozen terminal windows
For remote development, it is especially useful because your shell keeps running on the server even if your local connection drops.
Installing tmux
On macOS with Homebrew:
brew install tmux
On Debian or Ubuntu:
sudo apt update
sudo apt install tmux
On Fedora:
sudo dnf install tmux
Check that it is installed:
tmux -V
You should see something like:
tmux 3.4
Starting your first session
Create a new session:
tmux new -s work
This starts a session named work.
At the bottom of the screen you will see a status bar. You are now inside tmux.
If you want to leave the session running and return to your normal shell, press:
Ctrl-b d
That means:
Ctrl-bis the default tmux prefixdmeans detach
To reconnect later:
tmux attach -t work
Listing and managing sessions
List active sessions:
tmux ls
Kill a session:
tmux kill-session -t work
Rename a session from inside tmux:
Ctrl-b $
This is useful when you start with a generic name and want something more descriptive later.
Splitting the window into panes
One of the main reasons to use tmux is pane management.
Split vertically:
Ctrl-b %
Split horizontally:
Ctrl-b "
Now you can run different commands side by side. A common setup might be:
- editor in one pane
- test runner in another
- logs in a third
Move between panes:
Ctrl-b arrow-key
For example:
Ctrl-b Left
Ctrl-b Right
Ctrl-b Up
Ctrl-b Down
Creating and switching windows
A tmux session can contain multiple windows, and each window can contain multiple panes.
Create a new window:
Ctrl-b c
Move to the next window:
Ctrl-b n
Move to the previous window:
Ctrl-b p
Choose a window from a list:
Ctrl-b w
This works well when one session represents one project and each window is a different task.
A minimal .tmux.conf
Here is a simple configuration that makes tmux friendlier without overcomplicating it:
set -g mouse on
set -g history-limit 10000
set -g base-index 1
setw -g pane-base-index 1
unbind C-b
set -g prefix C-a
bind C-a send-prefix
set -g status-bg black
set -g status-fg green
set -g status-left "[#S] "
set -g status-right "%Y-%m-%d %H:%M"
What this does:
- enables mouse support
- increases scrollback history
- starts window and pane numbering at
1 - changes the prefix from
Ctrl-btoCtrl-a - adds a simple status bar
After saving the file to ~/.tmux.conf, reload it from inside tmux:
tmux source-file ~/.tmux.conf
A practical daily workflow
A simple way to use tmux every day:
- Start a session for the project:
bash tmux new -s blog - Open your editor in the first pane.
- Split another pane for:
bash python manage.py runserver - Open another window for git commands.
- Detach when done:
text Ctrl-b d - Reattach later:
bash tmux attach -t blog
This gives you a repeatable working environment with very little setup.
Useful commands to remember
Some tmux commands are worth memorizing early:
Ctrl-b d detach session
Ctrl-b c new window
Ctrl-b n next window
Ctrl-b p previous window
Ctrl-b % split vertically
Ctrl-b " split horizontally
Ctrl-b x kill pane
Ctrl-b w list windows
Ctrl-b ? help
You do not need to learn everything at once. Just sessions, panes, and detach/attach already provide most of the value.
Final thoughts
tmux is one of those tools that feels awkward for a day or two and then quickly becomes hard to live without. Start with a small setup, learn a few key bindings, and use it consistently for one project. That is usually enough to make the workflow stick.
Once the basics feel natural, you can expand into custom keybindings, session restoration, plugins, and more advanced layouts.