1001Ferramentas
πŸ–₯️Generators

tmux Command Builder

Build common tmux commands: new-session, attach, split, rename, kill, new-window.


  

tmux in depth: sessions, windows, panes, and the persistent terminal workflow

tmux β€” short for terminal multiplexer β€” is a small, BSD-licensed program written by Nicholas Marriott in 2007 as the spiritual successor to GNU Screen. It lets you run multiple sessions, windows, and panes inside a single terminal emulator, detach from a running shell, close your laptop, log in from a different machine, and re-attach exactly where you left off. For developers who live in SSH sessions to remote servers, tmux is often the difference between losing a 10-hour build to a flaky Wi-Fi connection and shrugging it off.

This generator produces the exact tmux invocation for the most common operations (new-session, attach, split, rename, kill). Below you will find a deep reference on the conceptual model, the default key bindings, configuration via ~/.tmux.conf, plugin ecosystem (TPM, resurrect, continuum, yank), and how tmux compares to Screen and the newer Rust-based Zellij.

The three-layer model: session, window, pane

  • Session β€” the outermost container, persists across detach/attach. Typically one per project.
  • Window β€” a "tab" inside a session. Each window has its own layout of panes.
  • Pane β€” a rectangular subdivision of a window running an independent shell. Up to dozens per window if your terminal is wide enough.

Sessions live in the tmux server (one per user, started on first command). When the server has at least one session it keeps your shells alive even after every client disconnects. Kill the server (tmux kill-server) and everything dies β€” there is no on-disk persistence by default.

Essential CLI commands

tmux new -s dev               # create session named "dev"
tmux ls                        # list active sessions
tmux a -t dev                  # attach to session "dev"
tmux a                         # attach to most recent session
tmux a -d -t dev               # attach, detaching any other clients
tmux kill-session -t dev       # destroy a single session
tmux kill-server               # destroy every session
tmux rename-session -t old new # rename without detaching
ssh -t user@host tmux a        # SSH straight into a tmux attach

Default key bindings (after the prefix key)

The prefix key is Ctrl-b by default. Almost every interactive command is "prefix, then key". Many users remap this to Ctrl-a (Screen-compatible, more ergonomic on QWERTY).

  • c β€” new window | n / p β€” next / previous | , β€” rename | 0-9 β€” jump to window N | w β€” interactive window list.
  • % β€” split pane vertically | " β€” split horizontally | arrow keys β€” move between panes | z β€” zoom (fullscreen the current pane) | x β€” kill pane | { / } β€” swap panes.
  • d β€” detach from session | $ β€” rename session | s β€” interactive session switcher.
  • [ β€” enter copy/scroll mode (use q to exit, / to search) | ] β€” paste the last buffer.
  • ? β€” show every binding currently active.

Configuration via ~/.tmux.conf

# remap prefix to Ctrl-a (Screen-style)
unbind C-b
set -g prefix C-a
bind C-a send-prefix

# enable mouse for resize/select/scroll
set -g mouse on

# 1-based indexing (matches the number row)
set -g base-index 1
setw -g pane-base-index 1

# bigger scrollback
set -g history-limit 50000

# vi-style copy mode
setw -g mode-keys vi

Reload without restarting with tmux source ~/.tmux.conf (or bind it to a key).

TPM and the essential plugins

TPM (Tmux Plugin Manager) is the de-facto package manager. Clone it to ~/.tmux/plugins/tpm, add run '~/.tmux/plugins/tpm/tpm' at the bottom of your config, and declare plugins with set -g @plugin '...'.

  • tmux-sensible β€” sane defaults (UTF-8, faster escape, larger history).
  • tmux-resurrect β€” save and restore the entire session state (windows, panes, working dirs, even running processes) across reboots. Prefix + Ctrl-s to save, prefix + Ctrl-r to restore.
  • tmux-continuum β€” runs resurrect automatically every 15 minutes and on tmux start, so you never lose work.
  • tmux-yank β€” copy to the system clipboard from copy mode (xclip, pbcopy, wl-copy depending on platform).
  • tmux-pain-control β€” vim-style pane navigation with hjkl.

tmux vs Screen vs Zellij

GNU Screen (1987) is the original multiplexer β€” still installed by default on many distros, rock-solid but with an outdated UI and limited scripting. tmux (2007) introduced a client-server architecture, real configuration, plugins, and is now the default in most dev environments. Zellij (2021, Rust) offers a discoverable UI with a status bar listing every binding, layouts in KDL files, and WebAssembly plugins β€” more user-friendly but less mature, with a smaller ecosystem.

FAQ

Does tmux replace GNU Screen? Functionally yes β€” every Screen feature has a tmux equivalent, and tmux adds vertical splits, named sessions, scripting, and a much larger plugin ecosystem. Screen is still useful when tmux is not installed on a locked-down server.

Do I need root to use tmux? No. tmux is a per-user process and stores its socket under /tmp/tmux-$UID/. Each user has their own server.

Can I run tmux inside tmux (nesting)? Yes, common on a local tmux that connects to a remote tmux. The inner instance also listens on Ctrl-b, so press the prefix twice (Ctrl-b Ctrl-b c) to talk to the inner session. Some users remap the inner prefix to Ctrl-s to avoid the double-tap.

Why does my colour scheme look wrong? Add set -g default-terminal "tmux-256color" and, for true-color terminals, set -as terminal-features ",xterm-256color:RGB" to your config. Vim/Neovim users may also need termguicolors.

Can two people share the same tmux session? Yes β€” both clients attach to the same session and see the same content live. Use tmux new-session -t shared to create independent windows on a shared session group if you want different views.

Related Tools