365 lines
9.0 KiB
HTML
365 lines
9.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self'; font-src 'self' data:; img-src 'self' data:; connect-src 'self'; base-uri 'self'; form-action 'self' https://defcon.social https://bsky.app;">
|
|
<meta http-equiv="X-Content-Type-Options" content="nosniff">
|
|
<link rel="stylesheet" href="../assets/css/style.css">
|
|
<link rel="icon" type="image/x-icon" href="../favicon.ico">
|
|
<script>
|
|
// Apply theme immediately to prevent flash
|
|
(function() {
|
|
const theme = localStorage.getItem('theme') ||
|
|
(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
})();
|
|
</script>
|
|
<title>tmux Cheatsheet - Cheatsheets - Launch Pad</title>
|
|
</head>
|
|
<body>
|
|
<button class="theme-toggle" id="themeToggle" aria-label="Toggle dark mode">
|
|
<svg class="theme-icon theme-icon-moon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg>
|
|
<svg class="theme-icon theme-icon-sun" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display: none;"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg>
|
|
</button>
|
|
<br/><br/>
|
|
<div class="name">
|
|
__ _______________________ _________._________________________
|
|
\_ _____/ \______ \ / _ \ / _____/ / _____/ | | \_ _____/
|
|
| __) | _/ / /_\ \ / \ ___ / \ ___ | | | __)_
|
|
| \ | | \ / | \ \ \_\ \ \ \_\ \ | |___ | \
|
|
\___ / |____|_ / \____|__ / \______ / \______ / |_______ \ /_______ /
|
|
\/ \/ \/ \/ \/ \/ \/
|
|
</div>
|
|
<div class="blog-page-header">
|
|
<div class="blog-header-content">
|
|
<a href="/cheatsheets" class="back-link" title="Back to Cheatsheets">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="42" height="42" viewBox="0 0 24 24" class="home-icon"><path fill="currentColor" d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>
|
|
</a>
|
|
<h1 class="blog-page-title">tmux Cheatsheet</h1>
|
|
</div>
|
|
</div>
|
|
<div class="blog-post-container">
|
|
<div class="blog-posts-container" style="max-width: 900px; margin: 0 auto;">
|
|
<div class="blog-post">
|
|
<div class="blog-post-content">
|
|
<p><a href="index.html">← Back to cheatsheets</a></p>
|
|
<p><a href="../index.html">← Home</a></p>
|
|
<hr>
|
|
<h2>Basic Commands</h2>
|
|
<h3>Starting and Attaching</h3>
|
|
<ul>
|
|
<li>tmux - Start new session</li>
|
|
</ul>
|
|
<ul>
|
|
<li>tmux new -s <name> - Start new named session</li>
|
|
</ul>
|
|
<ul>
|
|
<li>tmux attach -t <name> - Attach to session</li>
|
|
</ul>
|
|
<ul>
|
|
<li>tmux attach-session -t <name> - Attach to session (long form)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>tmux ls - List all sessions</li>
|
|
</ul>
|
|
<ul>
|
|
<li>tmux list-sessions - List all sessions (long form)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>tmux kill-session -t <name> - Kill a session</li>
|
|
</ul>
|
|
<ul>
|
|
<li>tmux kill-server - Kill all sessions</li>
|
|
</ul>
|
|
<h3>Prefix Key</h3>
|
|
<p>Default prefix is Ctrl+b. All commands below assume this prefix.</p>
|
|
<hr>
|
|
<h2>Sessions</h2>
|
|
<ul>
|
|
<li>s - List sessions</li>
|
|
</ul>
|
|
<ul>
|
|
<li>$ - Rename session</li>
|
|
</ul>
|
|
<ul>
|
|
<li>d - Detach from session</li>
|
|
</ul>
|
|
<ul>
|
|
<li>( - Switch to previous session</li>
|
|
</ul>
|
|
<ul>
|
|
<li>) - Switch to next session</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Windows</h2>
|
|
<ul>
|
|
<li>c - Create new window</li>
|
|
</ul>
|
|
<ul>
|
|
<li>, - Rename current window</li>
|
|
</ul>
|
|
<ul>
|
|
<li>w - List windows</li>
|
|
</ul>
|
|
<ul>
|
|
<li>n - Next window</li>
|
|
</ul>
|
|
<ul>
|
|
<li>p - Previous window</li>
|
|
</ul>
|
|
<ul>
|
|
<li>0-9 - Switch to window number</li>
|
|
</ul>
|
|
<ul>
|
|
<li>& - Kill current window</li>
|
|
</ul>
|
|
<ul>
|
|
<li>f - Find window by name</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Panes</h2>
|
|
<ul>
|
|
<li>% - Split pane vertically (left/right)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>" - Split pane horizontally (top/bottom)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>x - Kill current pane</li>
|
|
</ul>
|
|
<ul>
|
|
<li>z - Zoom/unzoom current pane</li>
|
|
</ul>
|
|
<ul>
|
|
<li>{ - Swap pane with previous</li>
|
|
</ul>
|
|
<ul>
|
|
<li>} - Swap pane with next</li>
|
|
</ul>
|
|
<ul>
|
|
<li>o - Switch to next pane</li>
|
|
</ul>
|
|
<ul>
|
|
<li>; - Switch to last active pane</li>
|
|
</ul>
|
|
<ul>
|
|
<li>q - Show pane numbers (then press number to switch)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>h - Select pane to the left</li>
|
|
</ul>
|
|
<ul>
|
|
<li>j - Select pane below</li>
|
|
</ul>
|
|
<ul>
|
|
<li>k - Select pane above</li>
|
|
</ul>
|
|
<ul>
|
|
<li>l - Select pane to the right</li>
|
|
</ul>
|
|
<ul>
|
|
<li>H - Resize pane left</li>
|
|
</ul>
|
|
<ul>
|
|
<li>J - Resize pane down</li>
|
|
</ul>
|
|
<ul>
|
|
<li>K - Resize pane up</li>
|
|
</ul>
|
|
<ul>
|
|
<li>L - Resize pane right</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Ctrl+h/j/k/l - Resize pane (alternative)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Alt+Arrow - Resize pane</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Space - Toggle between pane layouts</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Copy Mode</h2>
|
|
<ul>
|
|
<li>[ - Enter copy mode</li>
|
|
</ul>
|
|
<ul>
|
|
<li>] - Paste buffer</li>
|
|
</ul>
|
|
<ul>
|
|
<li>q - Exit copy mode</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Space - Start selection</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Enter - Copy selection</li>
|
|
</ul>
|
|
<ul>
|
|
<li>v - Start selection (vi mode)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>y - Copy selection (vi mode)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>p - Paste (vi mode)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>/ - Search forward</li>
|
|
</ul>
|
|
<ul>
|
|
<li>? - Search backward</li>
|
|
</ul>
|
|
<ul>
|
|
<li>n - Next match</li>
|
|
</ul>
|
|
<ul>
|
|
<li>N - Previous match</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Miscellaneous</h2>
|
|
<ul>
|
|
<li>t - Show clock</li>
|
|
</ul>
|
|
<ul>
|
|
<li>? - List all key bindings</li>
|
|
</ul>
|
|
<ul>
|
|
<li>: - Enter command mode</li>
|
|
</ul>
|
|
<ul>
|
|
<li>r - Reload config file</li>
|
|
</ul>
|
|
<ul>
|
|
<li>~ - Show messages</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Ctrl+z - Suspend tmux (send to background)</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Command Mode Commands</h2>
|
|
<ul>
|
|
<li>new-window -n <name> - Create named window</li>
|
|
</ul>
|
|
<ul>
|
|
<li>split-window -h - Split horizontally</li>
|
|
</ul>
|
|
<ul>
|
|
<li>split-window -v - Split vertically</li>
|
|
</ul>
|
|
<ul>
|
|
<li>select-pane -t <number> - Select pane by number</li>
|
|
</ul>
|
|
<ul>
|
|
<li>resize-pane -L 10 - Resize pane left by 10</li>
|
|
</ul>
|
|
<ul>
|
|
<li>resize-pane -R 10 - Resize pane right by 10</li>
|
|
</ul>
|
|
<ul>
|
|
<li>resize-pane -U 10 - Resize pane up by 10</li>
|
|
</ul>
|
|
<ul>
|
|
<li>resize-pane -D 10 - Resize pane down by 10</li>
|
|
</ul>
|
|
<ul>
|
|
<li>swap-pane -s <source> -t <target> - Swap panes</li>
|
|
</ul>
|
|
<ul>
|
|
<li>kill-pane -t <number> - Kill pane</li>
|
|
</ul>
|
|
<ul>
|
|
<li>kill-window -t <number> - Kill window</li>
|
|
</ul>
|
|
<hr>
|
|
<h2>Configuration</h2>
|
|
<h3>Config File Location</h3>
|
|
<ul>
|
|
<li>~/.tmux.conf (user config)</li>
|
|
</ul>
|
|
<ul>
|
|
<li>/etc/tmux.conf (system config)</li>
|
|
</ul>
|
|
<h3>Example Key Bindings</h3>
|
|
<p>Customize key bindings in your config:</p>
|
|
<pre><code># Change prefix key
|
|
unbind C-b
|
|
set-option -g prefix C-a
|
|
bind-key C-a send-prefix
|
|
|
|
# Custom window navigation
|
|
bind h select-pane -L
|
|
bind j select-pane -D
|
|
bind k select-pane -U
|
|
bind l select-pane -R
|
|
|
|
# Custom window splitting
|
|
bind | split-window -h
|
|
bind - split-window -v
|
|
unbind '"'
|
|
unbind %
|
|
|
|
# Reload config
|
|
bind r source-file ~/.tmux.conf \; display "Config reloaded!"</code></pre>
|
|
<h3>Common Settings</h3>
|
|
<pre><code># Change prefix to Ctrl+a
|
|
unbind C-b
|
|
set-option -g prefix C-a
|
|
bind-key C-a send-prefix
|
|
|
|
# Enable mouse support
|
|
set -g mouse on
|
|
|
|
# Start windows and panes at 1, not 0
|
|
set -g base-index 1
|
|
setw -g pane-base-index 1
|
|
|
|
# Renumber windows sequentially after closing any
|
|
set -g renumber-windows on
|
|
|
|
# Increase scrollback buffer
|
|
set -g history-limit 10000
|
|
|
|
# Enable vi mode
|
|
setw -g mode-keys vi
|
|
|
|
# Set default terminal mode to 256color
|
|
set -g default-terminal "screen-256color"
|
|
|
|
# Faster key repeat
|
|
set -s escape-time 0
|
|
|
|
# Reload config file
|
|
bind r source-file ~/.tmux.conf \; display "Config reloaded!"</code></pre>
|
|
<hr>
|
|
<h2>Tips</h2>
|
|
<ul>
|
|
<li>Use tmux -2 to force 256 color mode</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Use tmux -u to enable UTF-8</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Sessions persist after terminal closes</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Use tmuxinator or tmuxp for session management</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Ctrl+b then d to detach without killing session</li>
|
|
</ul>
|
|
<ul>
|
|
<li>Use tmux attach to reconnect to last session</li>
|
|
</ul>
|
|
<hr>
|
|
<p><a href="index.html">← Back to cheatsheets</a></p>
|
|
<p><a href="../index.html">← Home</a></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script async type="text/javascript" src="../blog/analytics.js"></script>
|
|
<script src="../theme.js"></script>
|
|
</body>
|
|
</html> |