详细分析 ▾
运行时依赖
版本
安装命令
点击复制技能文档
使用 gifgrep 搜索 GIF 提供商(Tenor/Giphy),在 TUI 中浏览,下载结果,并提取静帧或精灵图。
GIF-Grab(gifgrep 工作流程)
- 搜索 → 预览 → 下载 → 提取(静帧/精灵图),用于快速查看和分享。
快速开始
gifgrep cats --max 5
gifgrep cats --format url | head -n 5
gifgrep search --json cats | jq '.[0].url'
gifgrep tui "office handshake"
gifgrep cats --download --max 1 --format url
TUI + 预览
- TUI:
gifgrep tui "query" - CLI 静帧预览:
--thumbs(仅适用于 Kitty/Ghostty;静帧)
下载 + 显示
--download保存到~/Downloads--reveal在 Finder 中显示最后一次下载
静帧 + 精灵图
gifgrep still ./clip.gif --at 1.5s -o still.png
gifgrep sheet ./clip.gif --frames 9 --cols 3 -o sheet.png
- 精灵图 = 采样帧的单个 PNG 网格(非常适合快速查看、文档、PR、聊天)
- 调整参数:
--frames(数量)、--cols(网格宽度)、--padding(间距)
提供商
--source auto|tenor|giphy--source giphy需要GIPHY_API_KEYTENOR_API_KEY可选(如果未设置,使用 Tenor 演示密钥)
输出
--json打印结果数组(id、title、url、preview_url、tags、width、height)--format用于管道友好的字段(例如url)
环境调整
GIFGREP_SOFTWARE_ANIM=1强制软件动画GIFGREP_CELL_ASPECT=0.5调整预览几何形状GIFGREP_FORCE_16M=1即使终端支持真彩色,也强制使用 256 色
安装
使用 Homebrew(macOS/Linux)
brew install steipete/tap/gifgrep
使用 Go
go install github.com/steipete/gifgrep/cmd/gifgrep@latest
从源代码构建
git clone https://github.com/steipete/gifgrep.git
cd gifgrep
go build -o gifgrep ./cmd/gifgrep
使用方法
基本搜索
# 搜索带有默认限制的 GIF gifgrep search "happy birthday"# 限制结果数量 gifgrep search "happy birthday" --max 10
# 使用特定提供商 gifgrep search "happy birthday" --source tenor gifgrep search "happy birthday" --source giphy
TUI 模式
# 启动交互式 TUI gifgrep tui "cat"
# 导航 TUI: # - 箭头键或 hjkl:导航 # - Enter:选择 GIF # - d:下载 # - s:保存精灵图 # - q:退出
下载 GIF
# 搜索并下载单个 GIF gifgrep search "dog" --download --max 1# 下载多个 GIF gifgrep search "dog" --download --max 5
# 下载到特定目录 gifgrep search "dog" --download --output ./gifs
# 在 Finder 中显示(macOS) gifgrep search "dog" --download --reveal
提取静帧
# 在特定时间提取静帧 gifgrep still ./clip.gif --at 2.5s -o frame.png# 在百分比位置提取静帧 gifgrep still ./clip.gif --at 50% -o middle.png
# 自动确定最佳帧 gifgrep still ./clip.gif --best -o best.png
创建精灵图
# 创建精灵图 gifgrep sheet ./clip.gif -o sprite.png# 指定帧数和列数 gifgrep sheet ./clip.gif --frames 12 --cols 4 -o sprite.png
# 添加帧之间的填充 gifgrep sheet ./clip.gif --frames 9 --cols 3 --padding 10 -o sprite.png
# 自定义宽度 gifgrep sheet ./clip.gif --width 800 -o sprite.png
管道命令
# 获取 URL 列表 gifgrep search "cat" --format url# 结合其他工具使用 gifgrep search "cat" --format url | xargs wget
# 使用 jq 处理 JSON 输出 gifgrep search "cat" --json | jq '.[0].url'
# 预览前 3 个结果 gifgrep search "cat" --max 3 --thumbs
配置
API 密钥
对于 Giphy,需要 API 密钥:
export GIPHY_API_KEY="your-api-key-here"
对于 Tenor,API 密钥是可选的:
export TENOR_API_KEY="your-api-key-here"
配置文件
您可以在 ~/.config/gifgrep/config.toml 中创建配置文件:
default_source = "auto"
default_limit = 20
download_dir = "~/Pictures/GIFs"
示例工作流程
工作流程 1:查找 GIF 用于演示文稿
# 1. 在 TUI 中搜索 gifgrep tui "excited"# 2. 选择并下载 GIF # (在 TUI 中按 'd')
# 3. 创建精灵图用于预览 gifgrep sheet ~/Downloads/excited.gif --frames 9 --cols 3 -o ~/Downloads/excited-sprite.png
工作流程 2:批量下载多个 GIF
# 1. 搜索并保存 URL gifgrep search "programming" --max 20 --format url > urls.txt# 2. 全部下载 cat urls.txt | xargs -I {} wget {}
# 3. 或者使用 gifgrep 的内置下载功能 gifgrep search "programming" --max 20 --download
工作流程 3:提取帧用于文档
# 1. 下载 GIF gifgrep search "explain" --download --max 1
# 2. 在关键时刻提取静帧 gifgrep still ~/Downloads/explain.gif --at 1.2s -o ~/Downloads/explain-frame.png
高级用法
内容过滤器
# 安全搜索(giphy-only) gifgrep search "cat" --source giphy --rating g
# 过滤器(tenor-only) gifgrep search "cat" --source tenor --contentfilter high
媒体过滤器
# 方面比例 gifgrep search "cat" --ar wide
# 最小/最大尺寸 gifgrep search "cat" --minwidth 400 --maxwidth 800
语言和地区
# 设置语言 gifgrep search "cat" --lang fr
# 设置地区 gifgrep search "cat" --locale fr_FR
故障排除
问题:TUI 中的动画无法正常工作
尝试:
GIFGREP_SOFTWARE_ANIM=1 gifgrep tui "cat"
问题:颜色显示不正确
尝试:
GIFGREP_FORCE_16M=1 gifgrep tui "cat"
问题:Giphy 搜索失败
确保您已设置 GIPHY_API_KEY。您可以在 https://developers.giphy.com/ 获取一个。
问题:下载缓慢
尝试使用 --source tenor - Tenor 有时比 Giphy 快。
相关项目
许可证
MIT 许可证。有关详细信息,请参阅 LICENSE 文件。
贡献
欢迎贡献!请参阅 https://github.com/steipete/gifgrep 的 CONTRIBUTING.md。