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
740
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.6k
Python ウェブアプリケーションのためのプロファイラの実装 // Implementation of a profiler for Python web applications
ymyzk
2
5.3k
CAMPHOR- のスケジュール管理を支える技術 // Schedule Management in CAMPHOR-
ymyzk
1
590
技術カンファレンスのススメ / Tech Conference
ymyzk
0
460
Proper Tail Calls - New Feature in ECMAScript 2015
ymyzk
1
360
Modern JavaScript - Introduction to ECMAScript 2015 & 2016
ymyzk
0
220
コンテナ型仮想化入門 / Introduction to container-based virtualization
ymyzk
0
330
計算機科学実験及び演習のための Git / Git for Hardware and Software Laboratory Project
ymyzk
0
240
漸進的型付けについて語る会 オープニング / Gradual Typing Opening
ymyzk
0
490
Other Decks in Programming
See All in Programming
Kaigi on Rails 2024 - Rails APIモードのためのシンプルで効果的なCSRF対策 / kaigionrails-2024-csrf
corocn
5
3.4k
Googleのテストサイズを活用したテスト環境の構築
toms74209200
0
270
Synchronizationを支える技術
s_shimotori
1
150
PLoP 2024: The evolution of the microservice architecture pattern language
cer
PRO
0
1.7k
カラム追加で増えるActiveRecordのメモリサイズ イメージできますか?
asayamakk
4
1.6k
役立つログに取り組もう
irof
27
8.7k
Progressive Web Apps für Desktop und Mobile mit Angular (Hands-on)
christianliebel
PRO
0
110
cXML という電子商取引の トランザクションを支える プロトコルと向きあっている話
phigasui
3
2.3k
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
7
2.8k
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.1k
Why Spring Matters to Jakarta EE - and Vice Versa
ivargrimstad
0
1k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
210
Featured
See All Featured
The Invisible Side of Design
smashingmag
297
50k
The World Runs on Bad Software
bkeepers
PRO
65
11k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Git: the NoSQL Database
bkeepers
PRO
425
64k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
290
Making Projects Easy
brettharned
115
5.9k
Writing Fast Ruby
sferik
626
61k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
37
1.8k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
A Modern Web Designer's Workflow
chriscoyier
692
190k
Optimizing for Happiness
mojombo
376
69k
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