Skip to content

March-77/RGUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RGUI

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

本地运行

  1. 安装 rg

Windows:

winget install BurntSushi.ripgrep.MSVC

macOS:

brew install ripgrep
  1. 创建虚拟环境并安装依赖
python -m venv .venv
.\.venv\Scripts\python -m pip install -r requirements.txt
  1. 启动应用
.\.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

方案一:PyInstaller

安装:

.\.venv\Scripts\python -m pip install pyinstaller

Windows 打包为 .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

方案二:Nuitka

安装:

.\.venv\Scripts\python -m pip install nuitka ordered-set zstandard

Windows:

.\.venv\Scripts\python -m nuitka --standalone --enable-plugin=tk-inter --windows-console-mode=disable --output-dir=build main.py

macOS:

./.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 二进制一起打包分发

About

基于 ripgrep 与 CustomTkinter 的跨平台桌面全文搜索工具。

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages