工具与资源phiresky.github.io
Rga:Ripgrep,还能搜索 PDF、电子书、Office 文档和压缩包
Rga: Ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz
2019 — 2020,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
Rga(ripgrep-all)是 ripgrep 的封装,让你用熟悉的 ripgrep 语法直接搜索 PDF、EPUB、Office 文档以及 zip/tar.gz 等压缩包中的文本。它通过适配器把不同格式转换成可搜索的流,并带有缓存和 fzf 集成。文章介绍了它的原理、用法和局限。
为什么经久不衰:它把 ripgrep 的速度和命令行体验扩展到日常杂乱的文档与压缩包里,解决了“内容明明在文件中却 grep 不到”的痛点,其 --pre、适配器链和缓存思路多年后仍有参考价值。
HN 评论精选
作者说明 rga 通过包装保留了缓存、递归和文件类型匹配等优势,并正为自定义提取器链重构,卡在 Rust 流式接口设计上。
我是这个工具的作者 :) 很高兴看到它被发到这里,我自己还在积极使用。也看看 README 里的 fzf 集成。目前主分支正在重构,以支持自定义提取器(调用其他工具)和更灵活的提取器链。ripgrep 本身通过 --pre 标志集成了调用自定义提取器的功能,但在这里加上后,我们可以保留 rga 包装器的好处:更准确的文件类型匹配、缓存、递归进入压缩包、适配器链、中间没有慢的 shell 脚本等。遗憾的是,在重写以支持这一点时我卡住了,没能想清楚如何在 Rust 中干净地设计。在稳定版中,每个适配器的主要接口是 fn(Read, Write) -> ();为了支持自定义适配器链,我得改成 fn(Read) -> Read,让每个链式适配器包装读取流并在读取时转换。但这样我在线程处理等方面遇到问题,还有一个至今没搞清楚的随机死锁 :/
phiresky查看英文原文
Developer of the tool here :) Glad to see it posted here, I still actively use it myself. Also check out the fzf integration in the README: https://github.com/phiresky/ripgrep-all/blob/master/doc/rga-fzf.gif Currently the main branch is undergoing a refactor to add support for having custom extractors (calling out to other tools), and more flexible chains of extractors. Ripgrep itself has functionality integrated to call custom extractors with the `--pre` flag, but by adding it here we can retain the benefits of the rga wrapper (more accurate file type matchers, caching, recursion into archives, adapter chaining, no slow shell scripts in between, etc). Sadly, during rewriting it to allow this, I kind of got hung up and couldn't manage to figure out how to cleanly design that in Rust. I'd be really glad if a Rust expert could help me out here: In the currently stable version, the main interface of each "adapter" is `fn(Read, Write) -> ()`. To allow custom adapter chaining I have to change it to be `fn(Read) -> Read` where each chained adapter wraps the read stream and converts it while reading. But then I get issues with how to handle threading etc, as well as a random deadlock that I haven't figured out how to solve so far :/
预索引的 Recoll 与 ripgrep 类即时搜索可以互补,个人搜索可走向内容数据库工作流。
我很喜欢看到个人搜索出现快速而灵活的方案。我最近在玩 Recoll 做内容全文搜索。因为它预先索引内容,搜索相当快,也能方便地给文件加标签元数据。值得思考基于 ripgrep 的工具如何融入更通用的“搜索你的内容数据库”工作流,而不是只靠记忆或遍历文件系统路径。
ssivark查看英文原文
I love that we’re seeing fast & flexible solutions for personal search. I’ve recently been playing with Recoll for full-text-search on content. Since it indexes content up front, the search is pretty fast. It can also easily accommodate tag metadata on files. It would be interesting to consider how ripgrep based tools can fit into generically broad “search your database of content” workflows (as opposed to remember or go through your file system paths).
低频场景可直接用 ripgrep 的 --pre,不必额外依赖 rga。
或者,如果你的使用频率足够低、不需要缓存,而且不想多依赖一个工具,直接配置 ripgrep 使用 --pre 标志即可(rga 做的正是这件事)。配置和 gist 见相关链接。
ronjouch查看英文原文
Or, if your usage is sufficiently infrequent to not need caching and if you'd rather not depend on one more tool, simply configure ripgrep to use a `--pre` flag (which is what rga is doing :). See config and gist at https://github.com/BurntSushi/ripgrep/issues/1252
类似功能在 lesspipe 等预处理器中早有先例。
啊,我们绕了一圈,又重新实现了 lesspipe。
woodruffw查看英文原文
Ah, we've come full circle and reimplemented lesspipe[1][2]. [1]: https://manpages.debian.org/jessie/less/lesspipe.1.en.html [2]: https://www.openwall.com/lists/oss-security/2014/11/23/2
历次讨论
同类还值得读
直接在浏览器中启动 Linux 内核
Boot a linux kernel right inside your browser.
Fabrice Bellard 的 JSLinux 页面,用 JavaScript 在浏览器里启动一个 Linux 内核,并提供一个可交互的终端环境。
工具与资源上首页 5 次 · 2011–2025bellard.orgHacker News 未公开功能与行为清单(2018)
A List of Hacker News's Undocumented Features and Behaviors (2018)
数据科学家 Max Woolf 整理的 Hacker News 未公开功能与行为清单,涵盖投票机制、排名算法、账号惩罚等社区运作细节。
工具与资源上首页 5 次 · 2019–2025github.comMapSCII:在终端中用盲文和 ASCII 渲染地图
MapSCII – Braille and ASCII map renderer for the console
MapSCII 是一个在命令行终端里渲染地图的开源工具,用盲文字符和 ASCII 字符把地理数据画成可交互浏览的字符地图。
工具与资源上首页 5 次 · 2017–2025github.com顶尖大学的免费在线课程
Free Online Courses from Top Universities
Open Culture 整理的一份免费在线课程合集,汇集了全球顶尖大学(如 MIT、斯坦福、耶鲁等)向公众开放的网络课程资源,涵盖音频、视频等多种形式。
工具与资源上首页 5 次 · 2010–2022openculture.com淘气字符串:容易引发用户输入问题的字符串清单
Naughty Strings: A list of strings likely to cause issues as user-input data
一个 GitHub 仓库,收录了大量容易让程序出问题的用户输入字符串,如特殊字符、emoji、SQL 注入片段、系统命令等,供开发者用于测试输入处理逻辑。
工具与资源上首页 4 次 · 2015–2020github.com