获取
- 作者仓库星标 8,603
- 作者仓库 claude-code-tips
- 领域
- 通用
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @ykdojo · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- Windows
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 命令执行
- 网络行为
- 允许外网请求
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
tmux send-keys -t <session_name> 'Your Reddit query here' Enter
sleep 30 # wait for response (adjust as needed, up to 90s for complex searches)
tmux capture-pane -t <session_name> -p -S -500 # capture output
# Reddit Fetch
## Method 1: Gemini CLI (Try First)
Use Gemini CLI via tmux. It can browse, summarize, and answer complex questions about Reddit content.
Pick a unique session name (e.g., `gemini_abc123`) and use it consistently throughout.
### Setup
```bash
tmux new-session -d -s <session_name> -x 200 -y 50
tmux send-keys -t <session_name> 'gemini -m gemini-3-pro-preview' Enter
sleep 3 # wait for Gemini CLI to load
```
### Send query and capture output
```bash
tmux send-keys -t <session_name> 'Your Reddit query here' Enter
sleep 30 # wait for response (adjust as needed, up to 90s for complex searches)
tmux capture-pane -t <session_name> -p -S -500 # capture output
```
If the captured output shows an API error (e.g., quota exceeded, model unavailable), kill the session and retry without the `-m` flag (just `gemini` with no model argument). This falls back to the default model.
### How to tell if Enter was sent
Look for YOUR QUERY TEXT specifically. Is it inside or outside the bordered box?
**Enter NOT sent** - your query is INSIDE the box:
```
╭─────────────────────────────────────╮
│ > Your actual query text here │
╰─────────────────────────────────────╯
```
**Enter WAS sent** - your query is OUTSIDE the box, followed by activity:
```
> Your actual query text here
⠋ Our hamsters are working... (processing)
╭────────────────────────────────────────────╮
│ > Type your message or @path/to/file │
╰────────────────────────────────────────────╯
```
Note: The empty prompt `Type your message or @path/to/file` always appears in the box - that's normal. What matters is whether YOUR query text is inside or outside the box.
If your query is inside the box, run `tmux send-keys -t <session_name> Enter` to submit.
### Cleanup when done
```bash
tmux kill-session -t <session_name>
```
### If Gemini fails completely
If retrying without `-m` also fails, fall back to Method 2 below.
---
## Method 2: curl with Reddit JSON API (Fallback)
Reddit's public JSON API works by appending `.json` to any Reddit URL. Use this when Gemini is unavailable (quota exhausted, API errors, etc.).
### Listing hot/new/top posts
```bash
curl -s -L -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" \
"https://old.reddit.com/r/SUBREDDIT/hot.json?limit=15"
```
Replace `hot` with `new`, `top`, or `rising` as needed. For `top`, add `&t=day` (or `week`, `month`, `year`, `all`).
### Fetching a specific post + comments
```bash
curl -s -L -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" \
"https://old.reddit.com/r/SUBREDDIT/comments/POST_ID.json?limit=20"
```
The response is a JSON array: `[0]` is the post, `[1]` is the comment tree.
### Searching within a subreddit
```bash
curl -s -L -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" \
"https://old.reddit.com/r/SUBREDDIT/search.json?q=QUERY&restrict_sr=on&sort=new&limit=15"
```
### Parsing the JSON
Use jq to extract what you need:
```bash
# List posts
curl -s -L -o /tmp/reddit_result.txt -w "%{http_code}" \
-H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" \
'https://old.reddit.com/r/SUBREDDIT/hot.json?limit=15'
jq -r '.data.children[] | .data | "\(.title)\n \(.score) pts | \(.num_comments) comments | u/\(.author) | id: \(.id)\n"' /tmp/reddit_result.txt
# List comments from a specific post (the [1] element has comments)
jq -r '.[1].data.children[] | select(.kind == "t1") | .data | "u/\(.author) (\(.score) pts):\n \(.body[:300])\n"' /tmp/reddit_thread.txt
```
Key details:
- Fetch to temp file first, then parse - avoids pipe-related encoding issues
- `-o /tmp/file` and `-w "%{http_code}"` saves the response and prints the HTTP status (useful for debugging empty responses)
- `-L` follows redirects (old.reddit.com sometimes redirects)
- Single-quoted URL avoids shell interpretation of `&` in query strings
- `.body[:300]` truncates long comment bodies (jq 1.7+)
### Rate limiting
Reddit's JSON API rate-limits aggressively:
- **Don't fire parallel requests.** Make them sequentially with `sleep 2` or `sleep 3` between each.
- If a request returns empty (0 bytes), wait 3-5 seconds and retry.
- If you get HTTP 429, back off for 10-15 seconds.
- A good pattern: fetch one search result listing, parse it, then fetch individual threads one at a time with delays.
章节与文件索引
按说明文件中的顺序排列。
方法 1:Gemini CLI(首先尝试)
发送查询并捕获输出
如何判断 Enter 是否已发送
如果双子座彻底失败
方法 2:使用 Reddit JSON API 进行curl(后备)
文件/命令 -> gemini_abc123 · gemini · Type your message or @path/to/file · tmux send-keys -t <session_name> Enter · .json · hot · new · top
内容校验值 -> e5f69f1e2597
当前原文的自动摘译,尚未人工审校。
方法 1:Gemini CLI(首先尝试)
通过 tmux 使用 Gemini CLI。它可以浏览、总结和回答有关 Reddit 内容的复杂问题。选择一个唯一的会话名称(例如,
gemini_abc123)并始终使用它。发送查询并捕获输出
如果捕获的输出显示 API 错误(例如,超出配额、模型不可用),请终止会话并在不使用
-m标志的情况下重试(仅使用gemini,不带模型参数)。这会退回到默认模型。如何判断 Enter 是否已发送
专门查找您的查询文本。它是在边框之内还是之外?输入“未发送”- 您的查询在框中: 输入“已发送”- 您的查询在框外,然后是活动: 注意:空提示
Type your message or @path/to/file始终出现在框中 - 这是正常的。重要的是您的查询文本是在框内还是框外。如果您的查询在框中,请运行tmux send-keys -t <session_name> Enter提交。如果双子座彻底失败
如果在不使用
-m的情况下重试也失败,请退回到下面的方法 2。方法 2:使用 Reddit JSON API 进行curl(后备)
Reddit 的公共 JSON API 的工作原理是将
.json附加到任何 Reddit URL。当 Gemini 不可用时(配额耗尽、API 错误等),请使用此选项。