# Tmux 101: A Comprehensive Guide Tmux is a powerful terminal multiplexer that allows you to manage multiple terminal sessions from a single window. This guide covers the basics of using tmux, including session management, window and pane operations, custom configurations, and how to switch between sessions. ## Session Management - **Start a New Session:** `tmux new -s session-name` - **Attach to an Existing Session:** `tmux attach -t session-name` or shorthand: `tmux a -t session-name` - **Detach from a Session:** Press `Ctrl+b` then `d`. - **List All Sessions:** `tmux list-sessions` or shorthand: `tmux ls` - **Kill a Session:** `tmux kill-session -t session-name` ## Window Management - **Create a New Window:** Press `Ctrl+b` then `c`. - **Switch to a Window:** Press `Ctrl+b` then `window-number`. - **Rename the Current Window:** Press `Ctrl+b` then `,`. - **Close the Current Window:** Press `Ctrl+b` then `&`. ## Pane Management - **Split Window Horizontally:** Press `Ctrl+b` then `%`. - **Split Window Vertically:** Press `Ctrl+b` then `"`. - **Navigate Between Panes:** Press `Ctrl+b` then use the arrow keys. - **Resize Panes:** Press `Ctrl+b` then hold `Ctrl` while pressing the arrow keys. - **Close the Current Pane:** Press `Ctrl+d`. ## Customizing Tmux - **Configure tmux:** Edit `~/.tmux.conf` to change tmux settings. For auto-detaching (custom behavior), consider scripting within your shell profile or tmux hooks. ## Switching Between Sessions - **Next Session:** Press `Ctrl+b` then `)`. - **Previous Session:** Press `Ctrl+b` then `(`. - **Select Session from List:** Press `Ctrl+b` then `s`. - **Switch to a Specific Session:** `tmux switch-client -t session-name` ## Essential Tips - Remember `Ctrl+b` is the default prefix for tmux commands; this can be customized in your `~/.tmux.conf`. - Sessions, windows, and panes are persistent across disconnections, making tmux ideal for remote work. - Practice navigating between sessions, windows, and panes to improve your workflow efficiency.