tmux

tmux

What’s tmux

  • A terminal multiplexer
  • Allow open multiple tabs (multiple terminals)

Why we need tmux

  • Keep your working session alive
  • tmux will not be terminated when connection is lost

Advantage of tmux:

  • Multiple sessions, windows, panes
    • sessions -browser
      • tmux command will open a new session
    • window -tab
      • One session can have multiple windows
    • pane -spit window
      • A window can be split into multiple panes

Session

  • Create a new session (open a new browser)
    • $ tmux
    • Outside of tmux session
  • Detach current session
    • $ tmux detach
    • Inside of tmux session
  • Attach to previous session
    • $ tmux attach
    • Attach only if previous sessions exist
  • List opened sessions
    • $ tmux list-sessions
  • Attach to previous session by id
    • $ tmux attach -t session-id

tmux - bindkey and command

  • Defualt: Ctrl + b

  • Command:

  • The common command

  • For Pane

    1. <Ctrl+b> + ":進行水平分割
    2. <Ctrl+b> + %:進行垂直分割
    3. <Ctrl+b> + <方向鍵>:移動到其他 pane
    4. <Ctrl+b> + x:關閉目前的 pane
  • For Session
    1.<Ctrl+b> + d:把 session 放到背景(detach)
    2.$ tmux at:attach 到背景的 session
    3.$ tmux attach -t <number>: 開到指定的session
    4.$tmux kill-session [ <number> ]:刪除指定的session
    5.$tmux ls:展示所有的sessions

Costimize you tmux

  • create a config file ~/.tmux.conf
  • Look up on Internet for more details

tmux v.s. screen