NotePipe

approved

by jiezhengj

Copy text from Obsidian with file path and line number context, ready to paste into AI agent terminals. - This plugin has not been manually reviewed by Obsidian staff.

1 stars25 downloadsUpdated 21d agoMIT

NotePipe

English | 中文

Floating copy button in Obsidian

Pasted output in terminal


English

One-click copy from Obsidian with file path and line number context — paste directly into AI agent terminals (Claude Code, etc.).

Background

In desktop GUI AI agent tools, it's very convenient to select a piece of text or code in a document on the side of the window and add it directly to the chat box for discussion.

However, when using CLI-based agent tools in the terminal, it's not as seamless. I often found myself having to copy the document path first, and then copy the specific text content separately.

That's why I created this Obsidian plugin. When you select text in Obsidian and copy it via this plugin, it automatically attaches the file path and line number information, ready to be pasted directly into the terminal.

Preview

Select text → click the floating button → paste into terminal. The output uses Markdown blockquote format (>) so the AI can clearly distinguish your reference from your question.

Features

🔗 Copy with contextAssign a hotkey in Obsidian Settings → Hotkeys, then copy selected text with file path and line number
🎯 Floating buttonA button appears near your selection in both edit and reading mode
📝 Multi-scenarioEdit mode, reading mode, and file explorer are all supported
📂 Absolute pathsOutputs full filesystem paths by default — ready for terminal use
🧩 Customizable template7 template variables ({{path}}, {{selection}}, {{startLine}}, etc.)
🌐 Bilingual UIAutomatically matches your Obsidian language setting (English / Chinese)

Install

Open Obsidian and go to Community plugin marketplace — search "NotePipe" → Install → Enable.

Or manually:

cd /your-vault/.obsidian/plugins/
git clone https://github.com/jiezhengj/NotePipe.git
cd NotePipe
npm install
npm run build

Usage

ScenarioActionOutput
Edit mode — select textHotkey or command palette> /path/note.md:5
> selected text
Reading mode — select textClick floating button> /path/note.md:3-7
> multi-line selection
File explorer — select filesCommand palette → Copy> /path/note1.md

Template variables

VariableDescription
{{path}}File path
{{fileName}}Filename without extension
{{startLine}}Start line number (1-indexed)
{{endLine}}End line number
{{selection}}Selected text
{{lines}}Human-readable range ("Line 5" / "Lines 3-7")
{{folder}}Parent folder path

Path mode

ModeExampleWhen to use
absolute (default)/Users/xxx/vault/note.md:5Pasting into terminal
vault-relativenotes/daily.md:5Cross-machine portability

Hotkey

No default hotkey is set. To assign one:

  1. Open Obsidian Settings → Hotkeys
  2. Search "NotePipe: Copy with context"
  3. Assign your preferred shortcut (e.g. Cmd+Shift+C)
PlatformRecommendationNote
macOSCmd+Shift+CUsually available
WindowsCtrl+Shift+C or Alt+Shift+CCtrl+Shift+C may conflict with terminal
LinuxCtrl+Shift+C or Alt+Shift+CGNOME / Konsole use Ctrl+Shift+C for copy

Development

git clone https://github.com/jiezhengj/NotePipe.git
cd NotePipe
npm install
npm run dev    # watch mode
npm run build  # production
src/
├── main.ts                  # Plugin entry
├── settings.ts              # Settings tab
├── template-engine.ts       # Template engine
├── context-resolver.ts      # Context resolver
├── floating-button.ts       # Floating button
├── copy-interceptor.ts      # Always-copy mode
└── i18n/
    ├── index.ts             # Translation
    └── locales/
        ├── en.ts
        └── zh.ts

License

MIT


中文

在 Obsidian 中选中文本,一键复制为 path:line 格式,直接粘贴到 AI 终端(如 Claude Code)。

背景

在桌面版的 Agent 工具里,我可以很方便地在窗口右侧的文档里,选择一段文本/代码,添加到与 Agent 对话的对话框里,进行讨论。

但是如果用终端里的 CLI 版本的 Agent 工具,就没那么方便了,我经常要先复制文档路径,再复制具体内容文本。所以我做了这个 Obsidian 插件,在 Obsidian 里选中文本,再通过这个插件复制粘贴,到终端里就自动带上路径和行号的定位信息。

预览

选中文本 → 点击浮层按钮 → 粘贴到终端。输出采用 Markdown 引用块格式(> 前缀),AI 可以清晰区分引用内容和你的提问。

功能

🔗 附带上下文复制在 Obsidian 设置 → 快捷键中绑定后,一键复制选中文本并附带文件路径和行号
🎯 浮层按钮选中文本后选区右上角出现复制按钮,编辑/阅读模式均支持
📝 多场景支持编辑模式、阅读模式、文件列表均可使用
📂 绝对路径默认输出完整文件系统路径,终端中可直接定位
🧩 可配置模板7 个模板变量({{path}}{{selection}}{{startLine}} 等)
🌐 中英文双语自动跟随 Obsidian 语言设置

安装

打开 Obsidian 进入 社区插件市场 — 搜索 "NotePipe" → 安装 → 启用。

或手动安装:

cd /你的vault/.obsidian/plugins/
git clone https://github.com/jiezhengj/NotePipe.git
cd NotePipe
npm install
npm run build

使用

场景操作输出
编辑模式选中文本快捷键或命令面板> /path/note.md:5
> 选中文本
阅读模式选中文本点击浮层按钮> /path/note.md:3-7
> 多行内容
文件列表选中文件命令面板 → 复制> /path/note1.md

模板变量

变量说明
{{path}}文件路径
{{fileName}}文件名(无扩展名)
{{startLine}}起始行号(从 1 开始)
{{endLine}}结束行号
{{selection}}选中文本
{{lines}}可读行范围("Line 5" / "Lines 3-7")
{{folder}}父文件夹路径

路径模式

模式示例适用场景
absolute(默认)/Users/xxx/vault/note.md:5粘贴到终端使用
vault-relativenotes/daily.md:5跨机器可移植

快捷键

插件不预设默认快捷键。设置方式:

  1. 打开 Obsidian 设置 → 快捷键
  2. 搜索 "NotePipe: 复制并附带上下文"
  3. 绑定你习惯的快捷键(如 Cmd+Shift+C
平台推荐快捷键注意
macOSCmd+Shift+C一般无冲突
WindowsCtrl+Shift+CAlt+Shift+CCtrl+Shift+C 可能与终端冲突
LinuxCtrl+Shift+CAlt+Shift+CGNOME / Konsole 占用 Ctrl+Shift+C

开发

git clone https://github.com/jiezhengj/NotePipe.git
cd NotePipe
npm install
npm run dev    # 开发模式
npm run build  # 生产构建
src/
├── main.ts                  # 插件入口
├── settings.ts              # 设置页面
├── template-engine.ts       # 模板引擎
├── context-resolver.ts      # 上下文解析
├── floating-button.ts       # 浮层按钮
├── copy-interceptor.ts      # 始终复制模式
└── i18n/
    ├── index.ts             # 翻译函数
    └── locales/
        ├── en.ts
        └── zh.ts

许可证

MIT

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.