gl0bal01/tmux-layouts
GitHub: gl0bal01/tmux-layouts
基于 tmux 和 tmuxp 的预配置终端工作区布局集合,为渗透测试、恶意软件分析、OSINT 调查、CTF 竞赛及日常开发等场景提供一键启动、开箱即用的分屏工作环境。
Stars: 0 | Forks: 0
# tmux 布局



[tmux](https://github.com/tmux/tmux) 是一个终端复用器,提供持久会话、分屏和复制模式。[tmuxp](https://github.com/tmux-python/tmuxp) 允许你使用 YAML 定义会话,并通过一条命令启动它们。本仓库打包了一份经过调优的 `tmux.conf`(包含 Catppuccin 主题、合理的默认设置、鼠标复制修复)以及即开即用的 workspace 布局。
本项目是 [zellij-layouts](https://github.com/gl0bal01/zellij-layouts) 的姊妹项目——工作流相同,但使用不同的终端复用器。
## 快速开始
```
git clone https://github.com/gl0bal01/tmux-layouts ~/tmux-layouts
cd ~/tmux-layouts
make setup # one-time: ~/projects, ~/docker, ~/ops/{pentest,malware,osint,ctf}
make install # lint + symlink tmux.conf + copy layouts + bootstrap TPM
echo 'source ~/tmux-layouts/tmux-layouts.zsh' >> ~/.zshrc
exec zsh
```
然后启动任何布局(可以在裸终端中工作,**也可以**在现有的 tmux 会话中工作——tmuxp 会创建新会话并将客户端切换过去):
```
tp # multi-project workspace
tctf-new htb-apocalypse # ad-hoc CTF engagement: ~/ops/ctf/htb-apocalypse, session "ctf-htb-apocalypse"
```
如果 `~/.tmux.conf` 已经存在,`make install` 会在创建符号链接之前将其移动到 `~/.tmux.conf.bak.`——不会有任何文件被静默覆盖。
如果 tmux 服务器已经在运行,请运行 `tmux source-file ~/.tmux.conf`(或 `tmux kill-server` 后重新启动)以加载新配置。在执行 `make install` 期间,TPM 插件的安装会尽力进行;如果失败,请打开 tmux 并按 `prefix + I` 重试。
## 什么是布局?
tmuxp 布局是一个 `.yaml` 文件,它描述了:
- **窗口 (Windows)** — 你可以在其间切换的命名工作区(`prefix n` / `prefix p` / `prefix `)
- **窗格 (Panes)** — 窗口内的终端分屏
- **命令 (Commands)** — 在每个窗格中自动运行的命令(`watch git status`、`tail -f log` 等)
- **窗格标题** — 显示在窗格边框上的简短标签 + 窗格内部作为提醒的暗淡青色横幅
布局存放在 `~/.config/tmuxp/` 中。tmuxp 通过名称查找它们:
```
tmuxp load -y # loads ~/.config/tmuxp/.yaml
```
## 前置条件
- `tmux >= 3.2`(推荐 3.3+,以完全支持 Catppuccin 功能)
- `tmuxp >= 1.x` — `pipx install tmuxp` 或 `apt install tmuxp` / `brew install tmuxp`
- `git`, `python3`
- Linux 剪贴板后端:
- Wayland 会话:`wl-clipboard`(提供 `wl-copy`)
- X11 会话:`xclip`(首选)或 `xsel`
- 针对 `🏠 cockpit` 窗口的可选依赖:`btop`、`bunx` + `ccusage`
- 推荐安装 Nerd Font 或 Noto Color Emoji(窗口名称使用了 emoji)
## 你将获得什么
- **专属的 `tmux.conf`** — 无需追踪上游依赖,前缀键为 `C-a`
- 通过 TPM 实现 **Catppuccin Mocha** 状态栏
- **插件集** — `tmux-sensible`、`tmux-yank`、`tmux-pain-control`、`tmux-resurrect`、`tmux-continuum`、`tmux-fzf`、`tmux-thumbs`、`vim-tmux-navigator`、`catppuccin/tmux`
- **窗格边框标题** — 每个布局中的每个窗格都会设置一个显示在顶部边框的简短标题
- **提醒横幅** — 每个窗格的第一行会显示一个暗淡的青色提醒,列出该角色可用的工具/命令
- **鼠标复制修复** — 拖动越过边框时不再捕获跨窗格的内容
- **剪贴板自动检测** — Wayland (`wl-copy`)、X11 (`xclip`/`xsel`)、macOS (`pbcopy`)
- **7 个 tmuxp 布局** — `claude-projects`(动态生成的多项目布局)、`project`、`docker`、`pentest`、`malware-analysis`、`osint`、`ctf`
- **Shell 辅助命令** — `tp`、`tdk`、`tpt`、`tma`、`tos`、`tctf` 及其用于临时任务的 `*-new` 变体
## 可用布局
### `claude-projects` — 多项目工作区
```
tp # launch (session: "claude")
```
由 `generate-layout.sh` 生成的多项目窗口,每个窗口包含:
- **70% 左侧** — 主 `claude` shell(获得焦点)
- **30% 右侧** — 实时 `git status`(顶部)+ 日志尾部输出或 shell(底部)
以及固定窗口:`🏠 cockpit` (btop + ccusage) 和 `🧪 scratch`。
### `project` — 单项目
```
tp-new my-app # creates ~/projects/my-app + session "my-app"
tmuxp load -y project --start-directory ~/projects/anywhere # ad-hoc cwd
```
单个窗口,采用相同的 70/30 窗格模式 (claude / git / shell)。
### `docker` — Docker / Compose
```
tdk # launch (session: "docker", cwd: ~/docker)
tdk-new my-stack # creates ~/docker/my-stack, session "dk-my-stack"
```
| 窗口 | 窗格标题 |
|---|---|
| `🐳 cockpit` | `lazydocker` (自动检测,回退到 `watch docker ps`) · `compose` · `exec` |
| `📜 logs` | `logs` · `compose logs` |
| `🧪 scratch` | `scratch` · `scratch` |
### `pentest` — 渗透测试
```
tpt # launch (session: "pentest", cwd: ~/ops/pentest)
tpt-new acme-corp # creates ~/ops/pentest/acme-corp, session "pt-acme-corp"
```
| 窗口 | 窗格标题 |
|---|---|
| `🎯 cockpit` | `notes` · `shell` · `loot` |
| `🔎 recon` | `scan` · `subdomains` · `fuzz` · `probe` |
| `💥 exploit` | `msf` · `payload` · `listener` · `target` |
| `🔓 post` | `privesc` · `lateral` · `persist` · `exfil` |
| `📝 report` | `report` · `evidence` |
### `malware-analysis` — 恶意软件分析
```
tma # launch (session: "malware", cwd: ~/ops/malware)
tma-new emotet # creates ~/ops/malware/emotet, session "ma-emotet"
```
| 窗口 | 窗格标题 |
|---|---|
| `🧬 cockpit` | `notes` · `shell` · `samples` (实时) · `detect` |
| `🔬 static` | `strings` · `PE` · `disasm` · `yara` |
| `🧪 dynamic` | `sandbox` · `procmon` · `netcap` · `behavior` |
| `🌐 network` | `C2` · `pcap` |
| `📝 report` | `IoC` · `report` |
### `osint` — OSINT 调查
```
tos # launch (session: "osint", cwd: ~/ops/osint)
tos-new target-co # creates ~/ops/osint/target-co, session "os-target-co"
```
| 窗口 | 窗格标题 |
|---|---|
| `🕵️ cockpit` | `dossier` · `shell` · `evidence` |
| `👤 identity` | `username` · `email` · `phone` · `face` |
| `🌐 web` | `domain` · `wayback` · `search` · `fetch` |
| `📡 social` | `twitter` · `instagram` · `linkedin/gh` · `telegram` |
| `🗺️ geo` | `geoint` · `exif` |
| `📝 report` | `report` · `evidence` |
### `ctf` — CTF 竞赛
```
tctf # launch (session: "ctf", cwd: ~/ops/ctf)
tctf-new htb-apocalypse # creates ~/ops/ctf/htb-apocalypse, session "ctf-htb-apocalypse"
```
| 窗口 | 窗格标题 |
|---|---|
| `🏁 cockpit` | `tracker` · `flags` · `submit` |
| `🌐 web` | `requests` · `source` · `proxy` · `exploit` |
| `💥 pwn` | `gdb` · `disasm` · `pwntools` · `gadgets` |
| `🔐 crypto` | `repl` · `solve.py` · `tools` · `scratch` |
| `🔎 forensics` | `analyze` · `hex` · `stego` · `pcap` |
| `🧰 misc` | `solve` · `recon` · `decode` · `scratch` |
## 会话如何工作
tmux 会话在分离后仍会持续存在。多个会话可以并行运行,使用 `prefix s`(交互式选择器)在它们之间切换。
```
tmuxp load -y pentest -s acme-night # named session
tmuxp load -y pentest -s acme-night -d # detached (don't attach)
```
如果具有该名称的会话已经存在,tmuxp 会提示你是否连接。`-y` 会自动回答“是”。在 tmux 内部时,tmuxp 会以分离状态创建会话并切换客户端。在 tmux 外部时,它会创建并连接。
| 操作 | 命令 / 快捷键 |
|---|---|
| 列出会话 | `tls` (= `tmux list-sessions`) |
| 连接到会话 | `ta ` |
| 分离(保持运行) | `prefix d` |
| 切换会话(在 tmux 内) | `prefix s` |
| 关闭一个会话 | `tks ` |
| 关闭所有会话 | `tka` (= `tmux kill-server`) |
## 在 tmux 内导航
前缀键是 **`C-a`** (Ctrl+a)。先按前缀键,然后再按动作键。
### 窗口(标签页)
| 操作 | 快捷键 |
|---|---|
| 下一个 / 上一个窗口 | `prefix n` / `prefix p` |
| 按数字跳转到窗口 | `prefix 1`–`9` |
| 新建窗口(在当前 cwd 中) | `prefix c` |
| 重命名窗口 | `prefix ,` |
| 窗口选择器 | `prefix w` |
### 窗格
| 操作 | 快捷键 |
|---|---|
| 水平分割(相同 cwd) | `prefix _` |
| 垂直分割(相同 cwd) | `prefix -` |
| 移动焦点 | `prefix h/j/k/l` (或 `vim-tmux-navigator` 的 `C-h/j/k/l`) |
| 切换缩放(全屏窗格) | `prefix z` |
| 循环窗格布局 | `prefix Space` 会冲突——请使用 `prefix M-1`..`M-5` 调用内置布局 |
| 关闭窗格 | `prefix x` |
### 复制 / 滚动模式
| 操作 | 快捷键 |
|---|---|
| 进入复制模式 | `prefix Enter` |
| 开始选择 | `v` (vi 模式) |
| 按行选择 | `V` |
| 矩形选择 | `C-v` |
| 复制 | `y` |
| 搜索 | `/` (向前) / `?` (向后) |
| **提示复制(推荐)** | `prefix Space` (`tmux-thumbs` 会高亮显示 URL/路径/哈希/IP) |
### 重载 + 插件
| 操作 | 快捷键 |
|---|---|
| 重载 `~/.tmux.conf` | `prefix r` |
| 安装插件 (TPM) | `prefix I` |
| 更新插件 | `prefix U` |
| 保存会话 (resurrect) | `prefix C-s` |
| 恢复会话 | `prefix C-r` |
## Shell 设置
在 `~/.zshrc` 或 `~/.bashrc` 中 source 本仓库的辅助脚本:
```
source ~/tmux-layouts/tmux-layouts.zsh
```
这会为你提供以下别名以及 `th` / `thelp`,后者会在终端打印一份简短的参考。
### 别名
```
# tmux
alias t='tmux'
# Layout launchers — 在 tmux 内部与外部均可工作
alias tp='tmuxp load -y claude-projects' # multi-project workspace
alias tdk='tmuxp load -y docker' # docker workflow
alias tpt='tmuxp load -y pentest' # pentest workflow
alias tma='tmuxp load -y malware-analysis' # malware analysis
alias tos='tmuxp load -y osint' # osint investigation
alias tctf='tmuxp load -y ctf' # ctf competition
# Session 管理
alias tls='tmux list-sessions'
alias ta='tmux attach -t'
alias tks='tmux kill-session -t'
alias tka='tmux kill-server'
```
帮助:
```
th # show layout command reference
thelp # same as th
```
### 每次任务专用函数
```
# tp-new my-app → ~/projects/my-app, session "my-app"
# tdk-new stack → ~/docker/stack, session "dk-stack"
# tpt-new acme → ~/ops/pentest/acme, session "pt-acme"
# tma-new emotet → ~/ops/malware/emotet, session "ma-emotet"
# tos-new corp → ~/ops/osint/corp, session "os-corp"
# tctf-new htb → ~/ops/ctf/htb, session "ctf-htb"
```
所有这些函数都会执行 `mkdir -p` 创建目标目录,并调用 `tmuxp load -y -s --start-directory `。具体实现位于 `tmux-layouts.zsh` 中。
## 自定义 `claude-projects`
`layouts/claude-projects.yaml` 是生成的构建产物——请修改 `generate-layout.sh`,而不是直接修改 YAML 文件。
```
# generate-layout.sh
projects=(
"frontend:🌐::logs/dev.log"
"backend-api:🔌:api:logs/app.log"
"cli-tool:🛠️::" # no log → plain shell pane
# "my-project:🚀::logs/dev.log"
)
```
格式:`"dirname:emoji:label:logfile"`
- `dirname` — `~/projects/` 下的子目录
- `emoji` — 窗口图标
- `label` — 窗口显示名称(如果为空,默认为 `dirname`)
- `logfile` — 相对于项目目录的 tail 目标文件路径(如果省略,则为普通的 shell 窗格)
然后运行 `make install`。
为了将你的个人项目排除在仓库之外,可以将 `generate-layout.sh` 复制为 `generate-layout.local.sh` 并在那里进行编辑——Makefile 会优先使用 `*.local.sh`,并且 `.gitignore` 已经将其排除## 自定义 tmux
将 `tmux.conf.local.example` 复制到 `~/.tmux.conf.local` 并进行编辑。主 `tmux.conf` 会在插件初始化之前 source 它,因此你可以覆盖 `@-options`(例如 Catppuccin 风格、状态栏位置、自定义绑定)。
```
cp tmux.conf.local.example ~/.tmux.conf.local
# 编辑 ~/.tmux.conf.local
tmux source-file ~/.tmux.conf
```
## Make 目标
```
make # regenerate layouts/claude-projects.yaml
make install # lint + regenerate + symlink tmux.conf + copy layouts + bootstrap TPM
make uninstall # remove installed layouts and ~/.tmux.conf symlink (keeps backups + TPM)
make clean # remove generated + installed files
make setup # create ~/projects, ~/docker, ~/ops/{pentest,malware,osint,ctf}
make lint # validate YAML syntax + tmux.conf parses
make list # show installed layouts
make tpm # bootstrap TPM and install plugins (idempotent)
make help # show all targets
```
## 复制 / 粘贴与剪贴板
此配置通过 `MouseDragEnd1Pane` → `copy-pipe-no-clear` 修复了常见的“跨越窗格边框拖动会捕获相邻窗格内容”的 bug。有两种同样好用的复制方式:
1. **鼠标拖动** — 在单个窗格内按住左键并拖动。释放选区后,将通过 `tmux-yank` 自动复制到系统剪贴板。**拖动时不要按住 Shift**——Shift 会绕过 tmux 而使用终端原生的选择功能,这会捕获整个网格(包括其他窗格)。这是终端的行为,而不是 tmux 的 bug。
2. **键盘提示(推荐)** — `prefix Space` 会激活 `tmux-thumbs`。URL、路径、哈希值和 IP 都会带有提示键被高亮显示。按下提示键即可复制。无需使用鼠标。
Vi 模式复制:`prefix Enter` 进入复制模式,`v` 开始选择,`y` 复制。
剪贴板后端会在 tmux 启动时自动检测——当设置了 `$WAYLAND_DISPLAY` 时,优先使用 Wayland 的 `wl-copy`;否则依次回退使用 `xclip` → `xsel` → `pbcopy`。
## 提示
- **窗格边框标题丢失了?** 安装后需要按 `prefix r`(或运行 `tmux source-file ~/.tmux.conf`)。如果没有新的配置,`pane-border-status` 是关闭的。
- **横幅换行成了两行。** 横幅长度大于窗格宽度。请调整窗格大小(`prefix M-1`..`M-5`,或用 `prefix z` 缩放)或缩短 YAML 中的横幅文本。
- **窗格中有长时间运行的 TUI?** 横幅会被 TUI(如 `btop`、`watch`、`tail -f`)覆盖。窗格标题仍然会显示在边框上。
- **窗口名称被运行的命令覆盖了?** 此配置设置了 `automatic-rename off` 和 `allow-rename off`,因此来自 YAML 的 `window_name` 会保持不变。
- **Resurrect / continuum 没有恢复?** 第一次运行会记录状态,随后的 tmux 启动才会进行恢复。手动操作:`prefix C-s` 保存,`prefix C-r` 恢复。
- **`tmuxp: command not found`** — 请运行 `pipx install tmuxp`(在基于 PEP 668 的发行版上推荐)或 `apt install tmuxp`。
- **状态栏看起来坏了** — 请安装 Nerd Font 或 Noto Color Emoji;某些终端还需要设置与 `$TERM` 匹配的 `set -g default-terminal "tmux-256color"`。
- **剪贴板后端在 Wayland 下卡在 xclip** — `WAYLAND_DISPLAY` 是在服务器启动时读取的。如果 tmux 在 Wayland 会话导出该变量之前启动,就会回退到 xclip。请使用 `tmux show -gv @override_copy_command` 进行验证;通过 `tmux kill-server` 并从支持 Wayland 的 shell 中重新启动来强制重新检测。
## 卸载
```
make uninstall # removes installed layouts and ~/.tmux.conf symlink (keeps backups + TPM)
make clean # also removes generated layouts/claude-projects.yaml
# 可选:rm -rf ~/.tmux/plugins
```
## 资源
- [tmux GitHub](https://github.com/tmux/tmux) · [tmux wiki](https://github.com/tmux/tmux/wiki)
- [tmuxp 文档](https://tmuxp.git-pull.com) · [tmuxp YAML 参考](https://tmuxp.git-pull.com/configuration/index.html)
- [TPM — tmux 插件管理器](https://github.com/tmux-plugins/tpm)
- [Catppuccin tmux 主题](https://github.com/catppuccin/tmux)
- [tmux-thumbs (提示复制)](https://github.com/fcsonline/tmux-thumbs)
## 许可证
MIT — 详见 [LICENSE](LICENSE)。
标签:Beacon Object File, Cutter, DAST, DevSecOps, Docker, ESC4, GitHub, Google搜索, IP 地址批量处理, Linux工具, OSINT, PB级数据处理, tmux, tmuxp, YAML配置, Zsh, 上游代理, 会话管理, 多项目管理, 安全运维, 安全防御评估, 实时处理, 布局管理, 开发环境, 恶意代码分析, 恶意软件分析, 攻击路径可视化, 数据展示, 端口探测, 紫队, 红队, 终端复用, 终端工作流, 网络安全, 网络调试, 自动化, 配置文件, 隐私保护, 黑客工具