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
730
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
580
技術カンファレンスのススメ / Tech Conference
ymyzk
0
450
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
AWS認定資格を受験するにあたり、気づいたこと・実践していたことのまとめ
satoshi256kbyte
1
120
MLOps in Mercari Group’s Trust and Safety ML Team
cjhj
1
100
Unlocking Python's Core Magic
leew
0
110
M5Stack に色々な M5ユニットをつないで扱う為の新たなアプローチ
gob
0
200
文化が生産性を作る
jimpei
2
480
ACES Meet におけるリリース作業改善の取り組み
fukucheee
0
110
AWS CDKを用いたセキュアなCI/CDパイプラインの構築 / Build a secure CI/CD pipeline using AWS CDK
seike460
PRO
3
500
複数プロダクトの技術改善・クラウド移行に向き合うチームのフレキシブルなペア・モブプログラミングの実践 / Flexible Pair Programming And Mob Programming
honyanya
0
140
上手に付き合うコンポーネントテスト
quramy
3
1.2k
標準ライブラリの動向とイテレータのパフォーマンス
makki_d
3
190
WEBアプリケーションにおけるAWS Lambdaを用いた大規模な非同期処理の実践
delhi09
PRO
7
3.7k
DjangoNinjaで高速なAPI開発を実現する
masaya00
0
420
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
What's new in Ruby 2.0
geeforr
341
31k
Bash Introduction
62gerente
608
210k
Optimizing for Happiness
mojombo
375
69k
How to train your dragon (web standard)
notwaldorf
87
5.6k
No one is an island. Learnings from fostering a developers community.
thoeni
19
2.9k
Scaling GitHub
holman
458
140k
Fireside Chat
paigeccino
32
2.9k
Building Applications with DynamoDB
mza
90
6k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
26
1.9k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
249
21k
10 Git Anti Patterns You Should be Aware of
lemiorhan
653
59k
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