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.7k
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
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
500
Other Decks in Programming
See All in Programming
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
100
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
330
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
Jakarta EE meets AI
ivargrimstad
0
580
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
Outline View in SwiftUI
1024jp
1
320
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
290
Featured
See All Featured
It's Worth the Effort
3n
183
27k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Typedesign – Prime Four
hannesfritz
40
2.4k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
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