cheatsheets/tmux.html

409 lines
10 KiB
HTML

<!doctype html>
<html lang='en' class='no-js '>
<head>
<meta charset='utf-8'>
<meta content='width=device-width, initial-scale=1.0' name='viewport'>
<link href='./assets/favicon.png' rel='shortcut icon'>
<meta content='/tmux.html' name='app:pageurl'>
<title>tmux cheatsheet</title>
<meta content='tmux cheatsheet' property='og:title'>
<meta content='tmux cheatsheet' property='twitter:title'>
<meta content='article' property='og:type'>
<meta content='https://assets.devhints.io/previews/tmux.jpg?t=20220707130803' property='og:image'>
<meta content='https://assets.devhints.io/previews/tmux.jpg?t=20220707130803' property='twitter:image'>
<meta content='900' property='og:image:width'>
<meta content='471' property='og:image:height'>
<meta content="The one-page guide to tmux: usage, examples, links, snippets, and more." name="description">
<meta content="The one-page guide to tmux: usage, examples, links, snippets, and more." property="og:description">
<meta content="The one-page guide to tmux: usage, examples, links, snippets, and more." property="twitter:description">
<link rel="canonical" href="https://devhints.io/tmux">
<meta name="og:url" content="https://devhints.io/tmux">
<meta content='Devhints.io cheatsheets' property='og:site_name'>
<meta content='CLI' property='article:section'>
<script async src='https://www.googletagmanager.com/gtag/js?id=UA-106902774-1'></script>
<script>
window.dataLayer=window.dataLayer||[];
function gtag(){dataLayer.push(arguments)};
gtag('js',new Date());
gtag('config','UA-106902774-1');
</script>
<meta property='page:depth' content='1'>
<script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
<script>(function(H){H.className=H.className.replace(/\bNoJs\b/,'WithJs')})(document.documentElement)</script>
<script>(function(d,s){if(window.Promise&&[].includes&&Object.assign&&window.Map)return;var js,sc=d.getElementsByTagName(s)[0];js=d.createElement(s);js.src='https://cdn.polyfill.io/v2/polyfill.min.js';sc.parentNode.insertBefore(js, sc);}(document,'script'))</script>
<!--[if lt IE 9]><script src='https://cdnjs.cloudflare.com/ajax/libs/nwmatcher/1.2.5/nwmatcher.min.js'></script><script src='https://cdnjs.cloudflare.com/ajax/libs/json2/20140204/json2.js'></script><script src='https://cdn.rawgit.com/gisu/selectivizr/1.0.3/selectivizr.js'></script><script src='https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js'></script><script src='https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js'></script><![endif]-->
<style>html{opacity:0}</style>
<link rel="stylesheet" href="./assets/2015/style.css?t=20220707130803">
<link href="./assets/style.css?t=20220707130803" rel="stylesheet" />
<link href="./assets/print.css?t=20220707130803" rel="stylesheet" media="print" />
</head>
<body>
<div class='all'>
<div class='site-header'>
<div class='container'>
This is <a href="."><em>Devhints.io cheatsheets</em></a> &mdash; a collection of cheatsheets I've written.
</div>
</div>
<script type='application/ld+json'>
{
"@context": "http://schema.org",
"@type": "NewsArticle",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://google.com/article"
},
"headline": "tmux cheatsheet",
"image": [ "https://assets.devhints.io/previews/tmux.jpg?t=20220707130803" ],
"description": "The one-page guide to tmux: usage, examples, links, snippets, and more."
}
</script>
<script type='application/ld+json'>
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "https://devhints.io/#cli",
"name": "CLI"
}
},{
"@type": "ListItem",
"position": 2,
"item": {
"@id": "https://devhints.io/tmux",
"name": "tmux"
}
}]
}
</script>
<div class='post-list -single -cheatsheet'>
<div class='post-item'>
<div class='post-headline -cheatsheet'>
<p class='prelude'><span></span></p>
<h1><span>tmux</span></h1>
<div class='pubbox'>
<div class='HeadlinePub' role='complementary'>
<script async src='https://pubsrv.devhints.io/carbon.js?serve=CE7IK5QM&placement=devhintsio&cd=pubsrv.devhints.io/s' id="_carbonads_js"></script>
<span class='placeholder -one'></span>
<span class='placeholder -two'></span>
<span class='placeholder -three'></span>
<span class='placeholder -four'></span>
</div>
</div>
</div>
<div class='post-content -cheatsheet'>
<h3 id="commands">Commands</h3>
<pre><code>$ tmux
-u # UTF8 mode
-S ~/.tmux.socket
</code></pre>
<h4 id="sessions">Sessions</h4>
<pre><code>$ tmux new
$ tmux new -s session_name
$ tmux attach # Default session
$ tmux attach -t session_name
$ tmux switch -t session_name
$ tmux ls # List sessions
$ tmux detach
</code></pre>
<h4 id="windows">Windows</h4>
<pre><code>$ tmux new-window
</code></pre>
<h3 id="help">Help</h3>
<pre><code>C-b ?
</code></pre>
<h3 id="scrolling">Scrolling</h3>
<pre><code>C-b [ # Enter scroll mode then press up and down
</code></pre>
<h3 id="copypaste">Copy/paste</h3>
<pre><code>C-b [ # 1. Enter scroll mode first.
Space # 2. Start selecting and move around.
Enter # 3. Press enter to copy.
C-b ] # Paste
</code></pre>
<h3 id="panes">Panes</h3>
<pre><code>C-b % # vert
C-b " # horiz
C-b hkjl # navigation
C-b HJKL # resize
C-b o # next window
C-b q # show pane numbers
C-b x # close pane
C-b { or } # move windows around
</code></pre>
<h3 id="windows-1">Windows</h3>
<pre><code>C-b c # New window
C-b 1 # Go to window 1
C-b n # Go to next window
C-b p # Go to previous window
C-b w # List all window
</code></pre>
<h3 id="detachattach">Detach/attach</h3>
<pre><code>C-b d # Detach
C-b ( ) # Switch through sessions
$ tmux attach
</code></pre>
<h3 id="niceties">Niceties</h3>
<pre><code>C-b t # Time
</code></pre>
<h2 id="status-formats">Status formats</h2>
<pre><code>setw -g window-status-format `#[fg=8,bg=default]#I`
</code></pre>
<p>See <code>message-command-style</code> in the man page.</p>
<h3 id="attributecolors">Attribute/colors</h3>
<table>
<tbody>
<tr>
<td><code>#[fg=1]</code></td>
<td>standard color</td>
</tr>
<tr>
<td><code>#[fg=yellow]</code></td>
<td>yellow</td>
</tr>
<tr>
<td><code>#[bold]</code></td>
<td>bold</td>
</tr>
<tr>
<td><code>#[fg=colour240]</code></td>
<td>256 color</td>
</tr>
<tr>
<td><code>#[fg=default]</code></td>
<td>default</td>
</tr>
<tr>
<td><code>#[fg=1,bg=2]</code></td>
<td>combinations</td>
</tr>
<tr>
<td><code>#[default]</code></td>
<td>reset</td>
</tr>
</tbody>
</table>
<h3 id="colors">Colors</h3>
<ul>
<li><code>black</code> <code>red</code> <code>green</code> <code>yellow</code> <code>blue</code> <code>magenta</code> <code>cyan</code> <code>white</code></li>
<li><code>brightred</code> (and so on)</li>
<li><code>colour0</code><code>colour255</code></li>
<li><code>#333</code> (rgb hex)</li>
</ul>
<h3 id="attributes">Attributes</h3>
<ul>
<li><code>bold</code> <code>underscore</code> <code>blink</code> <code>noreverse</code> <code>hidden</code> <code>dim</code> <code>italics</code></li>
</ul>
<h3 id="variables">Variables</h3>
<table>
<tbody>
<tr>
<td><code>#(date)</code></td>
<td>shell command</td>
</tr>
<tr>
<td><code>#I</code></td>
<td>window index</td>
</tr>
<tr>
<td><code>#S</code></td>
<td>session name</td>
</tr>
<tr>
<td><code>#W</code></td>
<td>window name</td>
</tr>
<tr>
<td><code>#F</code></td>
<td>window flags</td>
</tr>
<tr>
<td><code>#H</code></td>
<td>Hostname</td>
</tr>
<tr>
<td><code>#h</code></td>
<td>Hostname, short</td>
</tr>
<tr>
<td><code>#D</code></td>
<td>pane id</td>
</tr>
<tr>
<td><code>#P</code></td>
<td>pane index</td>
</tr>
<tr>
<td><code>#T</code></td>
<td>pane title</td>
</tr>
</tbody>
</table>
<h2 id="options">Options</h2>
<pre><code>set -g status-justify [left|centre|right]
set -g status-left '...'
setw -g window-status-style
setw -g window-status-activity-style
setw -g window-status-bell-style
setw -g window-status-content-style
setw -g window-status-current-style
setw -g window-status-last-style
setw -g window-status-format
setw -g window-status-current-format
setw -g window-status-separator
</code></pre>
</div>
<ul class="social-list ">
<li class="facebook link hint--bottom" data-hint="Share on Facebook"><a href="https://www.facebook.com/sharer/sharer.php?u=https://devhints.io/tmux.html" target="share"><span class="text"></span></a></li>
<li class="twitter link hint--bottom" data-hint="Share on Twitter"><a href="https://twitter.com/intent/tweet?text=The%20ultimate%20cheatsheet%20for%20tmux.%20https://devhints.io/tmux.html" target="share"><span class="text"></span></a></li>
</ul>
</div>
</div>
<div class="about-the-site">
<div class="container">
<p class='blurb'>
<strong><a href=".">Devhints.io cheatsheets</a></strong> is a collection of cheatsheets I've written over the years.
Suggestions and corrections? <a href='https://github.com/rstacruz/cheatsheets/issues/907'>Send them in</a>.
<i class='fleuron'></i>
I'm <a href="http://ricostacruz.com">Rico Sta. Cruz</a>.
Check out my <a href="http://ricostacruz.com/til">Today I learned blog</a> for more.
</p>
<p class='back'>
<a class='big-button -back -slim' href='.#toc'></a>
</p>
<p>
</p>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script>
<script src="https://cdn.rawgit.com/rstacruz/unorphan/v1.0.1/index.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
<script>unorphan('h1, h2, h3, p, li, .unorphan')</script>
</body>
</html>