Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
tmux 入門 / Introduction to tmux
Search
Yusuke Miyazaki
May 28, 2017
Programming
0
750
tmux 入門 / Introduction to tmux
CAMPHOR- HOUSE で開催された,「CLI について語る会」
https://camphor.connpass.com/event/57358/
での発表資料です.
Yusuke Miyazaki
May 28, 2017
Tweet
Share
More Decks by Yusuke Miyazaki
See All by Yusuke Miyazaki
Adopting Kafka for the #1 job site in the world
ymyzk
1
7.7k
Python ウェブアプリケーションのためのプロファイラの実装 // Implementation of a profiler for Python web applications
ymyzk
2
5.3k
CAMPHOR- のスケジュール管理を支える技術 // Schedule Management in CAMPHOR-
ymyzk
1
600
技術カンファレンスのススメ / Tech Conference
ymyzk
0
470
Proper Tail Calls - New Feature in ECMAScript 2015
ymyzk
1
370
Modern JavaScript - Introduction to ECMAScript 2015 & 2016
ymyzk
0
220
コンテナ型仮想化入門 / Introduction to container-based virtualization
ymyzk
0
340
計算機科学実験及び演習のための Git / Git for Hardware and Software Laboratory Project
ymyzk
0
240
漸進的型付けについて語る会 オープニング / Gradual Typing Opening
ymyzk
0
510
Other Decks in Programming
See All in Programming
Haze - Real time background blurring
chrisbanes
1
510
nekko cloudにおけるProxmox VE利用事例
irumaru
3
440
Zoneless Testing
rainerhahnekamp
0
120
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
6
1.4k
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
500
103 Early Hints
sugi_0000
1
230
CSC305 Lecture 26
javiergs
PRO
0
140
良いユニットテストを書こう
mototakatsu
8
2.7k
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.3k
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
Featured
See All Featured
Bash Introduction
62gerente
608
210k
Adopting Sorbet at Scale
ufuk
73
9.1k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
A Philosophy of Restraint
colly
203
16k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
450
What's in a price? How to price your products and services
michaelherold
243
12k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Making the Leap to Tech Lead
cromwellryan
133
9k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Transcript
CLI ʹ͍ͭͯޠΔձ tmux ೖ Yusuke Miyazaki @ymyzk May 28th, 2017
CAMPHOR- HOUSE 1 / 30
͓͠ͳ͕͖ 1. ͡Ίʹ 2. tmux ͷػೳհ 3. tmux ͷ͍ํ 4.
tmux ͷ׆༻ 2 / 30
tmux ͱ? 3 / 30
tmux is a terminal multiplexer 4 / 30
terminal multiplexer? It lets you switch easily between several programs
in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. And do a lot more. — From http://tmux.github.io 5 / 30
tmux ͷػೳ 6 / 30
͜Μͳͱ͖͋Γ·ͤΜ͔? (λʔϛφϧͰ)͋Δ࡞ۀΛ͍͕ͯͨ͠, ผͷ࡞ۀΛ͍ͨ͠ Ͱ, લͷը໘ดͨ͘͡ͳ͍ ΤσΟλͰϓϩάϥϜΛॻ͖ͳ͕Β, ͦͷϓϩάϥϜΛί ϯύΠϧ/࣮ߦ͍ͨ͠ 7 /
30
͜Μͳ͜ͱͯ͠·ͤΜ͔? λʔϛφϧͷΟϯυλϒΛ։͚ྑ͍͕, ͍ʹͦ͘͏ 8 / 30
tmux Λ͏ͱ 1ͭͷλʔϛφϧͰηογϣϯ ɾ Οϯυ ɾ ϖΠϯΛͬͯ, ෳ ͷϓϩάϥϜΛ࣮ߦͰ͖Δ! 9
/ 30
͜Μͳ͜ͱ͋Γ·ͤΜ͔? 2 ࣮ߦʹ͕͔͔࣌ؒΔॲཧΛߦ͍ͬͯΔؒ, ผͷ࡞ۀΛ͍ͨ͠ SSH Ͱ࡞ۀ͍͕ͯͨ͠, ωοτϫʔΫ͕Εͯ, ࡞ۀ͕தஅ ͯ͠͠·ͬͨ !
͋ΔͰ࡞ۀ͍͕ͯͨ͠, ผͷʹҠಈͯ͠࡞ۀΛଓ͚ ͍ͨ 10 / 30
tmux Λ͏ͱ σλονͯ͠, ࡞ۀΛதஅग़དྷΔ ϓϩάϥϜΛόοΫάϥϯυͰ࣮ߦͨ͠·· Ξλονͯ͠, ࡞ۀΛ࠶։͢Δ͜ͱ͕ग़དྷΔ SSH ଓ͕Εͯ, Ξλον͢Εେৎ
ෳͷॴ͔Βಉ͡ηογϣϯΛΞλονͰ͖Δ 11 / 30
·ͱΊ: tmux Ͱग़དྷΔ͜ͱ 1ͭͷλʔϛφϧͰෳͷϓϩάϥϜΛ࣮ߦ (ηογϣϯ ɾ Οϯυ ɾ ϖΠϯ) ը໘
(Οϯυ) ΛΓସ͑Δ ΟϯυΛׂͯ͠͏ (ϖΠϯ) λʔϛφϧͰͷ࡞ۀΛதஅ ɾ ࠶։ (σλον ɾ Ξλον) ෳͷλʔϛφϧ͔Β1ͭͷηογϣϯΛಉ࣌ʹΞλον ෳͷϖΠϯʹಉ࣌ʹೖྗ etc 12 / 30
ͬͯΈͨ͘ͳΓ·͔ͨ͠? " 13 / 30
ͪΐͬͱدΓಓ # 14 / 30
൪֎ฤ: GUI Ͱμϝ? $ ྫ͑iTerm (macOS ༻) Ͱը໘ׂग़དྷΔ ηογϣϯΛΞλον ɾ
σλον͢Δػೳ͕ͳ͍ (ཁௐࠪ) OS ʹґଘͯ͠͠·͏ͷͰ, ଞͷ OS Ͱಉ͡ͷ͕͑ͳ͍ SSH ܦ༝Ͱαʔόʔʹଓͨ͠ࡍͳͲʹ͑ͳ͍ ͔ͬ͠Γ͏ͳΒ tmux ͷํ͕ྑͦ͞͏ 15 / 30
൪֎ฤ: ྨࣅͷϓϩδΣΫτ GNU Screen ػೳ tmux ʹࣅ͍ͯΔ ͪ͜Βͷํ͕͔ͳΓݹ͍ϓϩδΣΫτ (80ʙ) GPL
ϥΠηϯε (फڭతཧ༝͕͋Ε) Byobu screen tmux ͷϥούʔ 16 / 30
tmux ΛͬͯΈΑ͏ 17 / 30
Πϯετʔϧ Linux (Debian ܥ): apt install tmux macOS (Homebrew): brew
install tmux Windows: Bash on Windows ͰೖΔΒ͍͠...? (ཁݕূ) 18 / 30
ىಈ ɾ جຊૢ࡞ ɾ ऴྃ ىಈ: tmux جຊૢ࡞ Prefix-key some-key
Prefix-key ͷσϑΥϧτ Ctrl-b Ctrl-b Ctrl Λԡ͠ͳ͕Β b Λԡ͢ͷҙ มߋͰ͖·͢ (มߋͯ͠Δਓ͕ଟ͍ؾ͕͢Δ) ྫ Prefix c : Ctrl-b Λԡͯ͠, ҰΩʔΛͯ͠ c Λԡ͢ ৽نΟϯυ͕։͖·͢ ऴྃ: Οϯυ͕ͳ͘ͳΔͱউखʹऴྃ 19 / 30
ηογϣϯͷૢ࡞ σλον: Prefix d ηογϣϯΛσλον ϓϩάϥϜόοΫάϥϯυͰ࣮ߦ͞Ε·͢ ྲྀੴʹϚγϯΛ࠶ىಈ͢Δͱఀࢭ͠·͢ Ξλον: tmux attach
-t <session_name> σλονͨ͠ηογϣϯΛ։͘ ηογϣϯ໊ͷมߋ: Prefix $ 20 / 30
Οϯυૢ࡞ Οϯυ࡞: Prefix c ΟϯυΓସ͑: ࣍ͷΟϯυ: Prefix n લͷΟϯυ: Prefix
p x ൪ͷΟϯυ: Prefix <x> 21 / 30
ϖΠϯૢ࡞ ΟϯυΛׂͯ͠ϖΠϯΛ࡞ ॎʹׂ (ԣʹϖΠϯΛฒΔ): Prefix % ԣʹׂ (ॎʹϖΠϯΛฒΔ): Prefix "
ϖΠϯͷׂΛΊͯΟϯυʹ: Prefix ! ϖΠϯͷΓସ͑: Prefix o 22 / 30
ηογϣϯ ɾ Οϯυ ɾ ϖΠϯ 23 / 30
ηογϣϯ ɾ Οϯυ ɾ ϖΠϯ ηογϣϯ1 (Ξλον ɾ σλον͢Δͷ͜ͷ୯Ґ) Οϯυ1
(λϒʹ͍ۙ) ϖΠϯ1 (ׂ͞Εͨ1ͭͷ෦) ϖΠϯ2 Οϯυ2 ϖΠϯ1 Οϯυ3 ϖΠϯ1 ηογϣϯ2 ... 24 / 30
tmux Λ׆༻͠Α͏ 25 / 30
tmux ͷઃఆ tmux ͷΩʔόΠϯυઃఆϑΝΠϧͰมߋͰ͖Δ ઃఆ ~/.tmux.conf ʹஔ͘ Vi-like ͳઃఆ Emacs-like
ͳઃఆબΔ ࣗͷखʹͳ͡ΉઃఆΛ͍ͯ͘͠ ৽͍͠ઃఆΛಡΈࠐΉࡍͷҙ tmux source-file ~/.tmux.conf Λ࣮ߦ͢Δ͔ ͯ͢ͷηογϣϯΛऴྃͯ͠࠶ىಈ͢Δ 26 / 30
tmux.conf ͷྫ # Prefix ͷมߋ (Ctrl-t ʹ) unbind C-b set
-g prefix C-t bind C-t send-prefix # Οϯυͷ൪߸Λ 1-index ʹ (Ωʔྻͱἧͬͯײత) set -g base-index 1 # Prefix Ctrl-r ͰઃఆಡΈࠐΈ bind C-r source-file ~/.tmux.conf 27 / 30
͞Βʹৄ͘͠ ݱࡏͷઃఆ: Prefix ? ϚχϡΞϧ: man 1 tmux ઃఆΛ୳͢: GitHub
Ͱݕࡧ filename:tmux.conf @ymyzk ͷઃఆ https://github.com/ymyzk/dotfiles ʹ͋Γ·͢ ϓϥάΠϯ: Tmux Plugin Manager Tips: tmux ΞοϓσʔτͰઃఆͷ༷͕Α͘มΘΔͷͰ, ใͷ৽͠͞, ࣗͷ͍ͬͯΔ tmux ͷόʔδϣϯʹ ҙ! 28 / 30
·ͱΊ շదͳ CLI ڥʹ tmux ͷΑ͏ͳλʔϛφϧϚϧνϓϨΫ α͕ඞਢ tmux ͕खʹ߹Θͳ͍ਓ screen
byobu Λࢼͯ͠Έ ͍͍͔ͯ গͣͭ͠ઃఆΛՃͯ͠, ࣗͷखʹͳ͡ΉઃఆΛ 29 / 30
Happy Hacking with tmux!! 30 / 30