LabHub
学习 学习路径 课程

vim 与 tmux

tmux 是客户端-服务器

在 LabHub 中继续学习

一句话总结

tmux 中真正运行命令的是独立服务器进程,终端只是连接到它的客户端,因此 SSH 断开后任务和屏幕仍会保留。

概念图: 一句话总结 · 结构与使用 · 原文命令与标识符

结构与使用

tmux 由服务器、会话、窗口和窗格四层组成。前缀键与命令键分两步输入。日常只需会创建会话、后台创建、列出、连接和分离;“存在就连接,不存在就创建”的模式最适合作为常用入口。

它与 nohup 的区别是任务存活之外,屏幕内容和交互输入也保留。长期迁移、远程开发布局和多服务器操作都适合 tmux。创建新窗格时应继承当前目录;同步窗格输入很强大也很危险,应明确显示其状态。

会话是工作空间,窗口像标签页,窗格用于分屏。网络中断后重新连接原会话即可继续,不必重启工作。

原文命令与标识符

tmux new-session -A -s deploy      # 있으면 attach, 없으면 새로
Ctrl-b ,        창 이름 바꾸기
Ctrl-b w        창 목록에서 고르기
Ctrl-b d        떼어 내기(작업은 계속 돈다)
set -g history-limit 50000
tmux new-session -t deploy -s deploy-2   # 창은 공유, 보기는 따로

nohup

setsid

tmux attach

tmux new -s dev

c

%

"

Ctrl-b

Ctrl-a

bind C-a send-prefix

tmux new -s 이름

tmux new -d -s 이름

tmux ls

tmux attach -t 이름

d

tmux new -A -s dev

tmux new -s migration

nohup

-c "#{pane_current_path}"

cd

synchronize-panes

split-window -h

-v

base-index 1

pane-base-index 1

history-limit

Ctrl-b [

Ctrl-b

tmux-basics

tmux-panes