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
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
140
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
340
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
230
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
300
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
930
イベント駆動で成長して委員会
happymana
1
330
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
Featured
See All Featured
The Invisible Side of Design
smashingmag
298
50k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
The Language of Interfaces
destraynor
154
24k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
How to train your dragon (web standard)
notwaldorf
88
5.7k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Happy Clients
brianwarren
98
6.7k
Writing Fast Ruby
sferik
627
61k
Thoughts on Productivity
jonyablonski
67
4.3k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
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