RGUI 是一个基于 ripgrep (rg) 的跨平台桌面全文搜索工具,使用 Python 3 + CustomTkinter 构建,界面采用 Terminal 风格的暗色主题。
- 调用
rg进行全文搜索,结果实时流式输出,避免界面卡死 - 后台线程执行搜索,适合大目录扫描
- 顶部目录栏 + 搜索框,支持回车直接触发
- 中间结果区采用黑底绿字终端风格
- 搜索结果中的文件名高亮可点击
- 自动检测系统中的
rg,未安装时会在界面中提示 - 点击结果时优先使用系统默认应用打开文件
- 支持通过环境变量自定义“按行打开”命令
- Python 3.10+
- CustomTkinter
- ripgrep (
rg)
RGUI/
├─ main.py
├─ requirements.txt
├─ README.md
└─ rgui/
├─ __init__.py
├─ openers.py
├─ search.py
└─ ui.py
- 安装
rg
Windows:
winget install BurntSushi.ripgrep.MSVCmacOS:
brew install ripgrep- 创建虚拟环境并安装依赖
python -m venv .venv
.\.venv\Scripts\python -m pip install -r requirements.txt- 启动应用
.\.venv\Scripts\python main.py- 顶部“目录”选择要搜索的根目录
- 在“搜索”输入框中输入关键字并按 Enter
- 搜索结果会持续追加到中间结果区
- 点击绿色文件名即可打开目标文件
不同操作系统的“默认打开程序”并没有统一的跨平台“跳转到某一行”标准接口,因此 RGUI 默认会:
- 使用系统默认应用打开文件
- 在状态栏中提示对应行号
如果你希望点击结果时直接跳转到指定行,可以设置环境变量 RGUI_OPEN_CMD。
Visual Studio Code:
$env:RGUI_OPEN_CMD='code --goto "{path}:{line}"'macOS / Linux:
export RGUI_OPEN_CMD='code --goto "{path}:{line}"'Notepad++:
$env:RGUI_OPEN_CMD='C:\Program Files\Notepad++\notepad++.exe "{path}" -n{line}'说明:
- Windows
.exe需要在 Windows 上打包 - macOS
.app需要在 macOS 上打包 - 当前实现默认依赖目标机器已安装
rg
安装:
.\.venv\Scripts\python -m pip install pyinstallerWindows 打包为 .exe:
.\.venv\Scripts\python -m PyInstaller --noconfirm --windowed --name RGUI --collect-all customtkinter main.py产物通常位于:
dist/RGUI/RGUI.exe
macOS 打包为 .app:
./.venv/bin/python -m pip install pyinstaller
./.venv/bin/python -m PyInstaller --noconfirm --windowed --name RGUI --collect-all customtkinter main.py产物通常位于:
dist/RGUI.app
安装:
.\.venv\Scripts\python -m pip install nuitka ordered-set zstandardWindows:
.\.venv\Scripts\python -m nuitka --standalone --enable-plugin=tk-inter --windows-console-mode=disable --output-dir=build main.pymacOS:
./.venv/bin/python -m pip install nuitka ordered-set zstandard
./.venv/bin/python -m nuitka --standalone --enable-plugin=tk-inter --macos-create-app-bundle --output-dir=build main.py- 增加文件类型过滤和忽略规则设置
- 增加匹配关键字高亮
- 增加搜索历史与最近目录
- 支持把
rg二进制一起打包分发