First Kang134 downloadsHover over a folder in the file explorer to reveal a terminal icon; click it to open a real shell (PTY) docked at the bottom, rooted at that folder.
This README is bilingual: English sections first, 中文 sections below. 本说明为双语:英文在前,中文在后。
Folder Terminal is an Obsidian plugin that adds a terminal icon to every folder in the file explorer. Hover over a folder and click the icon to open a real shell (PTY) at the bottom of Obsidian, with the working directory automatically set to that folder.
⚠️ Desktop-only (depends on Node's
child_process); not available on mobile.
Highlights
vim / ssh / htop work normally, no native modules requiredPlatform notes: macOS requires python3 (Xcode Command Line Tools); Linux falls back to script when python3 is missing; Windows uses winpty when available, otherwise cmd.exe.
Obsidian 插件:鼠标移到文件浏览器中的文件夹上时,标题右侧出现「终端」图标;点击后在 Obsidian 当前面板下方打开一个真实 Shell(PTY)窗口,工作目录自动切换为该文件夹。
⚠️ 仅支持桌面端(依赖 Node 的
child_process),移动端不可用。
cd — opens a terminal already rooted at that folder's absolute path (including the vault root)pty.fork) creates a true pseudo-terminal, so interactive programs like vim / ssh / htop work without any native modulesTIOCSWINSZ keeps the PTY size in sync with the panel, so full-screen TUIs react instantlyCtrl/Cmd+F (or right-click → Search) to find text in the buffer, with match highlighting, prev/next navigation, live match count, and case-sensitive / regex / whole-word toggles↑ / ↓ recalls previous commands and ← / → / Home / End move the cursor within the linecd 到该文件夹的磁盘绝对路径(含库根目录,data-path="")pty.fork)创建真实伪终端,vim / ssh / htop 等交互程序可正常工作,无需任何原生模块TIOCSWINSZ 实时调整 PTY 尺寸,vim 内全屏程序也能即时感知Ctrl/Cmd+F(或右键 → 搜索)在缓冲区检索,支持高亮全部匹配、上/下一处跳转、实时计数,以及区分大小写 / 正则 / 全字匹配开关↑ / ↓ 回溯历史命令,← / → / Home / End 在行内移动光标Hover icon — 鼠标悬停文件夹时显示终端图标

Multi-tab terminal — 多标签终端与右键菜单

Per-tab settings — 标签设置弹窗

Option A — Community plugin browser (after this plugin is approved)
Option B — BRAT (for beta / pre-release testing)
https://github.com/FIRSTKANG/folder-terminal and confirmOption C — Manual
npm install && npm run buildmain.js, manifest.json, styles.css) into your vault's .obsidian/plugins/folder-terminal/方式 A — 社区插件市场(插件过审后可用)
方式 B — BRAT(用于抢先体验 beta / 未上架版本)
https://github.com/FIRSTKANG/folder-terminal 并确认方式 C — 手动安装
npm install && npm run buildmain.js、manifest.json、styles.css)复制到 vault 的 .obsidian/plugins/folder-terminal/npm install
npm run dev # watch 模式(产出 main.js)
npm run build # 生产构建(tsc 检查 + esbuild 打包)
npm run smoke:pty # PTY 链路冒烟测试(不依赖 Obsidian,可直接跑)
| Command (EN) | 命令(中文) | Description |
|---|---|---|
| Open terminal at vault root | 在库根目录打开终端 | Open/focus the bottom terminal rooted at the vault root |
| Open terminal at active note's folder | 在笔记所在文件夹打开终端 | Open/focus the bottom terminal rooted at the current note's folder |
| Setting (EN) | 设置项 | Description |
|---|---|---|
| Default shell | 默认 Shell | Empty = $SHELL (macOS default /bin/zsh); e.g. /bin/bash, /bin/fish |
| Font size | 字号 | Terminal font size (10–22px) |
| Color scheme | 配色方案 | Follow Obsidian theme / force dark / force light |
| Reuse terminal panel | 复用终端面板 | When on, re-clicking an icon focuses the same bottom panel's tab (default on) |
| Interface language | 界面语言 | Chinese / English / Follow system |
Each tab can also override shell / color scheme / font size / color tag individually: right-click a tab → Tab settings… 每个标签页还可以单独覆盖 Shell / 配色 / 字号 / 颜色标记:右键标签 → 「标签设置…」。
| Action (EN) | 操作 | How / 方式 |
|---|---|---|
| Switch | 切换标签 | Single click |
| Reorder | 排序 | Drag onto a target tab (insert before it) |
| Rename | 重命名 | Double-click the tab name, Enter to save / Esc to cancel |
| Restart session | 重启会话 | Right-click → Restart session |
| Tab settings | 标签设置 | Right-click → Tab settings… (per-tab shell / color scheme / font size / color tag) |
| Close | 关闭 | The × on the tab, or right-click → Close |
English: a MutationObserver keeps injecting a terminal icon into every folder title in the file explorer. Clicking it opens a new panel below the current one via workspace.getLeaf('split', 'horizontal'), where a custom ItemView renders xterm.js. A child_process.spawn('python3', ['-u', '-c', <pty-proxy.py>, $SHELL]) launches an embedded Python PTY proxy; fd3 is used as a resize-control channel, and pty.fork() creates a real pseudo-terminal so interactive programs work. No native modules are bundled — child_process, path, etc. are marked external and provided by the Obsidian desktop runtime.
中文:
文件浏览器 .nav-folder-title(MutationObserver 持续补注入图标)
│ 点击
▼
workspace.getLeaf('split', 'horizontal') → 当前面板下方新开面板
▼
registerView 自定义视图 → xterm.js 渲染终端
▼
child_process.spawn('python3', ['-u', '-c', <pty-proxy.py>, $SHELL])
│ fd0/1 = 键盘输入 / 终端输出;fd3 = 尺寸控制通道
▼
pty.fork() → 真实 PTY → /bin/zsh(或 $SHELL),工作目录 = vault 根 + 文件夹路径
关键点:
src/pty-proxy.py,构建时以字符串打包进 main.js),pty.fork() 创建真实伪终端后只做字节搬运。这样交互程序(vim/ssh)才能正常工作,且对 stdio 类型无要求。script 命令? macOS 上 Node/Electron 的 child_process 管道实际是 socketpair(libuv 行为),而 BSD 的 script 会对 stdin 做 tcgetattr,遇 socket 返回 EOPNOTSUPP 直接退出(已实测复现)。Python 代理没有这个检查。child_process、path 等 Node 内置模块标为 external,运行时由 Obsidian 桌面端提供。isDesktopOnly: true, not loaded on mobile.python3: requires Xcode Command Line Tools (prompts on first use, or run xcode-select --install).python3 falls back to script: still interactive, but resize sync degrades to stty (only effective at the shell prompt).cmd.exe (no PTY, interactive programs limited).Cmd+P) may still be intercepted by Obsidian; Ctrl+C / arrow keys are handled normally by the PTY..nav-files-container, etc.) may change across versions; if the icon disappears, update folderIcons.ts for the new DOM.python3/shell child processes.中文:
isDesktopOnly: true,移动端不加载。xcode-select --install)。script:仍可交互,但尺寸同步降级为 stty(仅 shell 提示符下生效)。cmd.exe 无 PTY,交互程序受限。.nav-files-container 等)随版本可能调整,若图标消失需按新版 DOM 更新 folderIcons.ts。src/
main.ts 插件入口:视图注册、设置、图标挂载、命令 (entry: view registration, settings, icon mount, commands)
folderIcons.ts 文件浏览器悬浮图标(MutationObserver + DOM 注入) (file-explorer hover icon)
terminalView.ts 多标签终端视图(xterm.js,标签/会话/拖拽/重命名管理) (multi-tab terminal view)
tabSettingsModal.ts 标签设置弹窗(每标签 Shell / 配色 / 字号 / 颜色标记覆盖) (per-tab settings modal)
pty.ts Shell 会话封装(python3 PTY 代理,Linux 回退 script,Windows winpty/cmd) (shell session wrapper)
pty-proxy.py PTY 代理脚本(构建时打包进 main.js) (PTY proxy, bundled at build time)
settings.ts 全局设置面板(shell / 字号 / 配色 / 复用开关 / 界面语言) (global settings panel)
i18n.ts 多语言字典与 t() 函数(zh-CN / en / 跟随系统) (i18n dictionary + t())
scripts/
pty-smoke.js PTY 链路冒烟测试(含尺寸控制通道验证) (PTY smoke test)
python3 is missing (Linux script, macOS prompts for CLT)cmd.exe)