Upgrade to Pro — share decks privately, control downloads, hide ads and more …

tmux 入門 / Introduction to tmux

tmux 入門 / Introduction to tmux

CAMPHOR- HOUSE で開催された,「CLI について語る会」 https://camphor.connpass.com/event/57358/ での発表資料です.

Yusuke Miyazaki

May 28, 2017
Tweet

More Decks by Yusuke Miyazaki

Other Decks in Programming

Transcript

  1. 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
  2. ·ͱΊ: tmux Ͱग़དྷΔ͜ͱ 1ͭͷλʔϛφϧͰෳ਺ͷϓϩάϥϜΛ࣮ߦ (ηογϣϯ ɾ ΢Οϯυ΢ ɾ ϖΠϯ) ը໘

    (΢Οϯυ΢) Λ੾Γସ͑Δ ΢Οϯυ΢Λ෼ׂͯ͠࢖͏ (ϖΠϯ) λʔϛφϧͰͷ࡞ۀΛதஅ ɾ ࠶։ (σλον ɾ Ξλον) ෳ਺ͷλʔϛφϧ͔Β1ͭͷηογϣϯΛಉ࣌ʹΞλον ෳ਺ͷϖΠϯʹಉ࣌ʹೖྗ etc 12 / 30
  3. ൪֎ฤ: GUI Ͱ͸μϝ? $ ྫ͑͹iTerm (macOS ༻) Ͱ΋ը໘෼ׂ͸ग़དྷΔ ηογϣϯΛΞλον ɾ

    σλον͢Δػೳ͕ͳ͍ (ཁௐࠪ) OS ʹґଘͯ͠͠·͏ͷͰ, ଞͷ OS Ͱಉ͡΋ͷ͕࢖͑ͳ͍ SSH ܦ༝Ͱαʔόʔʹ઀ଓͨ͠ࡍͳͲʹ͸࢖͑ͳ͍ ͔ͬ͠Γ࢖͏ͳΒ tmux ͷํ͕ྑͦ͞͏ 15 / 30
  4. Πϯετʔϧ Linux (Debian ܥ): apt install tmux macOS (Homebrew): brew

    install tmux Windows: Bash on Windows ͰೖΔΒ͍͠...? (ཁݕূ) 18 / 30
  5. ىಈ ɾ جຊૢ࡞ ɾ ऴྃ ىಈ: tmux جຊૢ࡞͸ Prefix-key some-key

    Prefix-key ͷσϑΥϧτ͸ Ctrl-b Ctrl-b ͸ Ctrl Λԡ͠ͳ͕Β b Λԡ͢ͷҙ มߋͰ͖·͢ (มߋͯ͠Δਓ͕ଟ͍ؾ͕͢Δ) ྫ Prefix c : Ctrl-b Λԡͯ͠, Ұ౓ΩʔΛ཭ͯ͠ c Λԡ͢ ৽ن΢Οϯυ΢͕։͖·͢ ऴྃ: ΢Οϯυ΢͕ͳ͘ͳΔͱউखʹऴྃ 19 / 30
  6. ηογϣϯ ɾ ΢Οϯυ΢ ɾ ϖΠϯ ηογϣϯ1 (Ξλον ɾ σλον͢Δͷ͸͜ͷ୯Ґ) ΢Οϯυ΢1

    (λϒʹ͍ۙ) ϖΠϯ1 (෼ׂ͞Εͨ1ͭͷ෦෼) ϖΠϯ2 ΢Οϯυ΢2 ϖΠϯ1 ΢Οϯυ΢3 ϖΠϯ1 ηογϣϯ2 ... 24 / 30
  7. tmux ͷઃఆ tmux ͷΩʔόΠϯυ౳͸ઃఆϑΝΠϧͰมߋͰ͖Δ ઃఆ͸ ~/.tmux.conf ʹஔ͘ Vi-like ͳઃఆ΍ Emacs-like

    ͳઃఆ΋બ΂Δ ࣗ෼ͷखʹͳ͡ΉઃఆΛ͍ͯ͘͠ ৽͍͠ઃఆΛಡΈࠐΉࡍͷ஫ҙ tmux source-file ~/.tmux.conf Λ࣮ߦ͢Δ͔ ͢΂ͯͷηογϣϯΛऴྃͯ͠࠶ىಈ͢Δ 26 / 30
  8. 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
  9. ͞Βʹৄ͘͠ ݱࡏͷઃఆ: Prefix ? ϚχϡΞϧ: man 1 tmux ઃఆΛ୳͢: GitHub

    Ͱݕࡧ filename:tmux.conf @ymyzk ͷઃఆ͸ https://github.com/ymyzk/dotfiles ʹ͋Γ·͢ ϓϥάΠϯ: Tmux Plugin Manager Tips: tmux ͸ΞοϓσʔτͰઃఆͷ࢓༷͕Α͘มΘΔͷͰ, ৘ใͷ৽͠͞΍, ࣗ෼ͷ࢖͍ͬͯΔ tmux ͷόʔδϣϯʹ஫ ҙ! 28 / 30
  10. ·ͱΊ շదͳ CLI ؀ڥʹ͸ tmux ͷΑ͏ͳλʔϛφϧϚϧνϓϨΫ α͕ඞਢ tmux ͕खʹ߹Θͳ͍ਓ͸ screen

    ΍ byobu Λࢼͯ͠Έ ͯ΋͍͍͔΋ গͣͭ͠ઃఆΛ௥Ճͯ͠, ࣗ෼ͷखʹͳ͡ΉઃఆΛ 29 / 30