-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
392 lines (335 loc) · 12.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>tmux</title>
<meta name="description" content="Tmux multiplexer">
<meta name="author" content="Konstantin Kolotyuk">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/sky.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h2>tmux</h2>
<p>
<small>Presented by <a href="http://twitter.com/kkolotyuk">@kkolotyuk</a></small>
</p>
</section>
<section>
<section>
<h3>A problem</h3>
<div class="fragment">
<p>I need more consoles!</p>
<img src="img/consoles.jpg">
</div>
</section>
<section>
<h3>Several terminals</h3>
<img src="img/before1.png" alt="Different terminals">
</section>
<section>
<h3>Tabs</h3>
<img src="img/before2.png" alt="Different tabs">
</section>
</section>
<section>
<h2>What is tmux?</h2>
<blockquote class="fragment">
“tmux is a terminal multiplexer.”
</blockquote>
</section>
<section>
<h2>What is terminal multiplexer?</h2>
<blockquote class="fragment" cite="https://en.wikipedia.org/wiki/Terminal_multiplexer">
“A terminal multiplexer is a software application that can be used to multiplex several virtual consoles, allowing a user to access multiple separate terminal sessions inside a single terminal window or remote terminal session.”
</blockquote>
</section>
<section>
<section>
<h2>Client-server model</h2>
<p>Tmux has client-server architecture</p>
<pre class="fragment">
<code data-trim class="1c">
$ tmux ls
failed to connect to server
</code>
</pre>
<div class="fragment">
<p>Start tmux server</p>
<pre>
<code data-trim class="1c">
$ tmux // start server, create default session
// and attache to it
</code>
</pre>
</div>
<img class="fragment" src="img/tmux-workflow-1.png">
</section>
<section>
<h2>Client-server model</h2>
<p>Commands</p>
<pre class="fragment">
<code data-trim class="1c">
$ tmux detach // detach from session (back to usual terminal)
$ tmux new-session -s foo -d // create new session with name "foo"
// and don't attach to it
$ tmux new-session -s bam -d // create new session with name "bam"
// and don't attach to it
$ tmux ls // list of sessions
0: 1 windows (created Sun Nov 16 15:28:53 2014) [168x41]
bam: 1 windows (created Sun Nov 16 15:29:53 2014) [168x41]
foo: 1 windows (created Sun Nov 16 23:49:49 2014) [168x41]
</code>
</pre>
<img class="fragment" src="img/tmux-workflow-3.png">
</section>
<section>
<h2>Client-server model</h2>
<pre class="fragment">
<code data-trim class="1c">
$ tmux attach -t 0 // attach to session with name 0
$ tmux attach -t 0 // !another client! attach to session with name 0
$ tmux attach -t foo // !another client! attach to session with name foo
</code>
</pre>
<img class="fragment" src="img/tmux-workflow-6.png">
</section>
<section>
<h2>Client-server model</h2>
<p>Work in background</p>
<ol>
<li class="fragment">Attach to session</li>
<li class="fragment">Run some processes</li>
<li class="fragment">Detach from session (or close terminal, or lose ssh connection etc)</li>
<li class="fragment">Attach again and get still running porcesses</li>
</ol>
<p class="fragment">Very usufull with SSH connection!</p>
</section>
</section>
<section>
<h2>Visual structure</h2>
<p>Tmux → Sessions → Windows → Panes</p>
<img src="img/structure.png">
<p class="fragment">Very usufull with SSH connection!</p>
</section>
<section>
<h2>Addressing</h2>
<p>[session]:[window].[pane]</p>
<pre>
<code data-trim class="1c">
$ tmux send-keys -t development:1.2 'cd ~/devproject' C-m
</code>
</pre>
</section>
<section>
<section>
<h2>Commands</h2>
<div class="fragment">
<h4>Console</h4>
<pre style="{width: 200px}">
<code data-trim class="1c">
$ tmux kill-session -t foo
</code>
</pre>
</div>
<div class="fragment">
<h4>Shortcuts</h4>
<p>Prefix + key</p>
</div>
<div class="fragment">
<h4>Command line</h4>
<p>Prefix + :</p>
</div>
</section>
<section>
<h2>Commands</h2>
<p class="fragment grow"><small>CLIENTS AND SESSIONS</small></p>
<p class="fragment grow"><small>WINDOWS AND PANES</small></p>
<p class="fragment grow"><small>KEY BINDINGS</small></p>
<p class="fragment grow"><small>OPTIONS</small></p>
</ul>
</section>
</section>
<section>
<h2>Configuration</h2>
<p>/etc/tmux.conf or ~/.tmux.conf</p>
<p>List of commands</p>
<pre>
<code data-trim class="python">
# Bind prefix to C-a
set -g prefix C-a
unbind C-b
# Bind spliting panes by | and -
bind | split-window -h
bind - split-window -v
# 256 colors
set -g default-terminal "screen-256color"
# Enable Vim keys
setw -g mode-keys vi
# Status bar style
set -g status-fg white
set -g status-bg black
# Window style
setw -g window-status-fg cyan
setw -g window-status-bg default
</code>
</pre>
</section>
<section>
<section>
<h3>Themes</h3>
<img src="img/theme1.png">
</section>
<section>
<h3>Themes</h3>
<img src="img/theme2.png">
</section>
<section>
<h3>Themes</h3>
<img src="img/theme3.png">
</section>
<section>
<h3>Themes</h3>
<img src="img/theme4.png">
</section>
</section>
<section>
<section>
<h2>Environments</h2>
<p>Configure custom environment for each project:</p>
<ol>
<li class="fragment">Create project.conf file</li>
<li class="fragment">Configure environment</li>
<li class="fragment">
Run tmux with
<pre>
<code data-trim class="1c">
$ tmux -f project.conf attach
</code>
</pre>
</li>
</ol>
</section>
<section>
<h2>Environments</h2>
<pre>
<code data-trim class="python">
source-file ~/.tmux.conf
# Create new session with name "ipm" and one window "frontend"
new-session -s ipm -n frontend -d
# Split window
split-window -h -t 1
split-window -v -t 1
split-window -v -t 2
# Open dirs and run rails server
send-keys -t ipm:frontend.1 'cd ~/projects/ipm-ui' C-m
send-keys -t ipm:frontend.1 'rails s' C-m
send-keys -t ipm:frontend.2 'cd ~/projects/ipm-ui' C-m
send-keys -t ipm:frontend.3 'cd ~/projects/ipm-ui' C-m
send-keys -t ipm:frontend.4 'cd ~/projects/ipm-ui' C-m
# Create window with name "backend"
new-window -n backend -c ~/projects/ipm-backend
split-window -h -t 1 -c ~/projects/ipm-backend
split-window -v -t 1 -c ~/projects/ipm-backend
split-window -v -t 2 -c ~/projects/ipm-backend
# Open dirs, run python server and workers
send-keys -t ipm:backend.1 '. env/bin/activate' C-m
send-keys -t ipm:backend.1 './runserver.py' C-m
send-keys -t ipm:backend.2 '. env/bin/activate' C-m
send-keys -t ipm:backend.2 './runworker.py' C-m
# SSH window
new-window -n ssh
# Postgres window
new-window -n psql
send-keys -t ipm:psql 'psql ipm ipm' C-m
</code>
</pre>
</section>
<section>
<h2>Environments</h2>
<img src="img/ipm.png">
</section>
</section>
<section>
<h2>Remote connection</h2>
<ol>
<li>Configure SSH server</li>
<li>Configure users restrictions</li>
<li>Create shared tmux session</li>
<li>Attach to session</li>
</ol>
</section>
<section>
<h2>Installation</h2>
<ul>
<li>Repository</li>
<li class="fragment">Make from <a href="http://tmux.sourceforge.net/">source</a> (latest version) </li>
<li class="fragment">PPA
<pre>
<code data-trim class="1c">
$ add-apt-repository ppa:pi-rho/dev
$ apt-get update
$ apt-get install tmux
</code>
</pre>
</li>
</ul>
</section>
<section>
<p>This presentation was made with <a href="https://github.com/hakimel/reveal.js">reveal.js</a>.</p>
<p>reveal.js + github pages</p>
</section>
<section>
<h1>THE END</h1>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
// Parallax scrolling
// parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
// parallaxBackgroundSize: '2100px 900px',
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>