tmux Guide

tmux is a terminal multiplexer that allows you to manage multiple terminal sessions within a single terminal window. It's especially useful for remote sessions, as it allows you to detach and reattach to sessions without losing your work.

tmux layout:

-session1
---window1
------pane1
------pane2
---window2
---window3
-session2
---window4
---window5
-session3
---window6

Basic Commands

  • Starting a New Session:

    tmux

    This command starts a new tmux session.

  • Detaching from a Session:
    Press Ctrl-b followed by d to detach from the current session.
  • Listing Sessions:

    tmux list-sessions

    This command lists all the active tmux sessions.

  • Attaching to an Existing Session:

    tmux attach -t [session-name]

    Replace [session-name] with the name of the session you want to attach to.

Window Management

  • Splitting the Window:

    • Horizontal Split: Press Ctrl-b followed by %.
    • Vertical Split: Press Ctrl-b followed by ".
  • Switching Between Panes:
    Press Ctrl-b followed by the arrow key in the direction of the pane you want to switch to.
  • Resizing Panes:
    Press Ctrl-b followed by Ctrl and an arrow key to resize the pane in the direction of the arrow.
  • Closing a Pane:
    Exit the shell of the pane or press Ctrl-b followed by x and then confirm with y.
  • Creating a New Window:
    Press Ctrl-b followed by c.
  • Switching Between Windows:

    • Press Ctrl-b followed by n for the next window.
    • Press Ctrl-b followed by p for the previous window.
  • Renaming a Window:
    Press Ctrl-b followed by ,.
  • Closing a Window:
    Close all the panes in the window or press Ctrl-b followed by & and then confirm with y.

Exiting and Customization

  • Exiting tmux Entirely:
    Detach from the session and then use:

    tmux kill-session -t [session-name]
  • Customizing tmux:
    tmux is highly customizable. Create a ~/.tmux.conf file in your home directory and add configurations to customize its behavior and appearance.

This is just a basic introduction to tmux. Explore its man page (man tmux) or various online resources for more features and capabilities.

Cheatsheet

功能快捷键
进入copy modectl-b [ 或者ctl-b pageup, 进入后可以通过滚轮、up/down进行滚屏
退出copy modeq
显示窗口信息ctl-b w
新建窗口ctl-b c
跳转窗口ctl-b 0,1,...(窗口编号)
横向切分panectl-b %
纵向切分panectl-b "

参考资料
Tmux Cheat Sheet
How do I scroll in tmux?
inline tmux help
tmux manual


黑暗森林
12 声望3 粉丝

弱小和无知不是生存的障碍,傲慢才是!


引用和评论

0 条评论