gog
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesegog
gog
Use for Gmail/Calendar/Drive/Contacts/Sheets/Docs. Requires OAuth setup.
gogSetup (once)
gog auth credentials /path/to/client_secret.jsongog auth add you@gmail.com --services gmail,calendar,drive,contacts,docs,sheetsgog auth list
Common commands
- Gmail search:
gog gmail search 'newer_than:7d' --max 10 - Gmail messages search (per email, ignores threading):
gog gmail messages search "in:inbox from:ryanair.com" --max 20 --account you@example.com - Gmail send (plain):
gog gmail send --to a@b.com --subject "Hi" --body "Hello" - Gmail send (multi-line):
gog gmail send --to a@b.com --subject "Hi" --body-file ./message.txt - Gmail send (stdin):
gog gmail send --to a@b.com --subject "Hi" --body-file - - Gmail send (HTML):
gog gmail send --to a@b.com --subject "Hi" --body-html "<p>Hello</p>" - Gmail draft:
gog gmail drafts create --to a@b.com --subject "Hi" --body-file ./message.txt - Gmail send draft:
gog gmail drafts send <draftId> - Gmail reply:
gog gmail send --to a@b.com --subject "Re: Hi" --body "Reply" --reply-to-message-id <msgId> - Calendar list events:
gog calendar events <calendarId> --from <iso> --to <iso> - Calendar create event:
gog calendar create <calendarId> --summary "Title" --from <iso> --to <iso> - Calendar create with color:
gog calendar create <calendarId> --summary "Title" --from <iso> --to <iso> --event-color 7 - Calendar update event:
gog calendar update <calendarId> <eventId> --summary "New Title" --event-color 4 - Calendar show colors:
gog calendar colors - Drive search:
gog drive search "query" --max 10 - Contacts:
gog contacts list --max 20 - Sheets get:
gog sheets get <sheetId> "Tab!A1:D10" --json - Sheets update:
gog sheets update <sheetId> "Tab!A1:B2" --values-json '[["A","B"],["1","2"]]' --input USER_ENTERED - Sheets append:
gog sheets append <sheetId> "Tab!A:C" --values-json '[["x","y","z"]]' --insert INSERT_ROWS - Sheets clear:
gog sheets clear <sheetId> "Tab!A2:Z" - Sheets metadata:
gog sheets metadata <sheetId> --json - Docs export:
gog docs export <docId> --format txt --out /tmp/doc.txt - Docs cat:
gog docs cat <docId>
Calendar Colors
- Use to see all available event colors (IDs 1-11)
gog calendar colors - Add colors to events with flag
--event-color <id> - Event color IDs (from output):
gog calendar colors- 1: #a4bdfc
- 2: #7ae7bf
- 3: #dbadff
- 4: #ff887c
- 5: #fbd75b
- 6: #ffb878
- 7: #46d6db
- 8: #e1e1e1
- 9: #5484ed
- 10: #51b749
- 11: #dc2127
Email Formatting
-
Prefer plain text. Usefor multi-paragraph messages (or
--body-filefor stdin).--body-file - -
Samepattern works for drafts and replies.
--body-file -
does not unescape
--body. If you need inline newlines, use a heredoc or\n.$'Line 1\n\nLine 2' -
Useonly when you need rich formatting.
--body-html -
HTML tags:for paragraphs,
<p>for line breaks,<br>for bold,<strong>for italic,<em>for links,<a href="url">/<ul>for lists.<li> -
Example (plain text via stdin):bash
gog gmail send --to recipient@example.com \ --subject "Meeting Follow-up" \ --body-file - <<'EOF' Hi Name, Thanks for meeting today. Next steps: - Item one - Item two Best regards, Your Name EOF -
Example (HTML list):bash
gog gmail send --to recipient@example.com \ --subject "Meeting Follow-up" \ --body-html "<p>Hi Name,</p><p>Thanks for meeting today. Here are the next steps:</p><ul><li>Item one</li><li>Item two</li></ul><p>Best regards,<br>Your Name</p>"
Notes
- Set to avoid repeating
GOG_ACCOUNT=you@gmail.com.--account - For scripting, prefer plus
--json.--no-input - Sheets values can be passed via (recommended) or as inline rows.
--values-json - Docs supports export/cat/copy. In-place edits require a Docs API client (not in gog).
- Confirm before sending mail or creating events.
- returns one row per thread; use
gog gmail searchwhen you need every individual email returned separately.gog gmail messages search
使用操作Gmail、Calendar、Drive、Contacts、Sheets和Docs。需要完成OAuth配置。
gog首次配置
gog auth credentials /path/to/client_secret.jsongog auth add you@gmail.com --services gmail,calendar,drive,contacts,docs,sheetsgog auth list
常用命令
- Gmail搜索:
gog gmail search 'newer_than:7d' --max 10 - Gmail单条邮件搜索(按单封邮件检索,忽略邮件线程):
gog gmail messages search "in:inbox from:ryanair.com" --max 20 --account you@example.com - 发送纯文本Gmail邮件:
gog gmail send --to a@b.com --subject "Hi" --body "Hello" - 发送多行内容Gmail邮件:
gog gmail send --to a@b.com --subject "Hi" --body-file ./message.txt - 从标准输入读取内容发送Gmail邮件:
gog gmail send --to a@b.com --subject "Hi" --body-file - - 发送HTML格式Gmail邮件:
gog gmail send --to a@b.com --subject "Hi" --body-html "<p>Hello</p>" - 创建Gmail草稿:
gog gmail drafts create --to a@b.com --subject "Hi" --body-file ./message.txt - 发送Gmail草稿:
gog gmail drafts send <draftId> - 回复Gmail邮件:
gog gmail send --to a@b.com --subject "Re: Hi" --body "Reply" --reply-to-message-id <msgId> - 列出日历事件:
gog calendar events <calendarId> --from <iso> --to <iso> - 创建日历事件:
gog calendar create <calendarId> --summary "Title" --from <iso> --to <iso> - 创建带颜色的日历事件:
gog calendar create <calendarId> --summary "Title" --from <iso> --to <iso> --event-color 7 - 更新日历事件:
gog calendar update <calendarId> <eventId> --summary "New Title" --event-color 4 - 查看日历颜色选项:
gog calendar colors - Drive搜索:
gog drive search "query" --max 10 - 列出联系人:
gog contacts list --max 20 - 获取Sheets数据:
gog sheets get <sheetId> "Tab!A1:D10" --json - 更新Sheets数据:
gog sheets update <sheetId> "Tab!A1:B2" --values-json '["A","B"],["1","2"]' --input USER_ENTERED - 追加Sheets数据:
gog sheets append <sheetId> "Tab!A:C" --values-json '["x","y","z"]' --insert INSERT_ROWS - 清空Sheets数据:
gog sheets clear <sheetId> "Tab!A2:Z" - 获取Sheets元数据:
gog sheets metadata <sheetId> --json - 导出Docs文档:
gog docs export <docId> --format txt --out /tmp/doc.txt - 查看Docs文档内容:
gog docs cat <docId>
日历颜色设置
- 使用查看所有可用的事件颜色(ID范围1-11)
gog calendar colors - 通过参数为事件添加颜色
--event-color <id> - 事件颜色ID(来自命令输出):
gog calendar colors- 1: #a4bdfc
- 2: #7ae7bf
- 3: #dbadff
- 4: #ff887c
- 5: #fbd75b
- 6: #ffb878
- 7: #46d6db
- 8: #e1e1e1
- 9: #5484ed
- 10: #51b749
- 11: #dc2127
邮件格式说明
- 优先使用纯文本格式。对于多段落邮件,使用参数(或通过
--body-file从标准输入读取内容)。--body-file - - 草稿和回复邮件同样支持参数。
--body-file - 参数不会解析转义字符
--body。如果需要换行,请使用here文档或\n格式。$'Line 1\n\nLine 2' - 仅当需要富文本格式时使用参数。
--body-html - 支持的HTML标签:用于段落,
<p>用于换行,<br>用于加粗,<strong>用于斜体,<em>用于链接,<a href="url">/<ul>用于列表。<li> - 示例(通过标准输入发送纯文本邮件):
bash
gog gmail send --to recipient@example.com \ --subject "Meeting Follow-up" \ --body-file - <<'EOF' Hi Name, Thanks for meeting today. Next steps: - Item one - Item two Best regards, Your Name EOF - 示例(HTML格式列表邮件):
bash
gog gmail send --to recipient@example.com \ --subject "Meeting Follow-up" \ --body-html "<p>Hi Name,</p><p>Thanks for meeting today. Here are the next steps:</p><ul><li>Item one</li><li>Item two</li></ul><p>Best regards,<br>Your Name</p>"
注意事项
- 设置环境变量,避免重复添加
GOG_ACCOUNT=you@gmail.com参数。--account - 编写脚本时,优先使用参数搭配
--json参数。--no-input - Sheets数据推荐通过参数传递,也可使用行内格式。
--values-json - Docs支持导出、查看内容和复制操作。如需在线编辑,需要使用Docs API客户端(gog暂不支持该功能)。
- 发送邮件或创建事件前会进行确认。
- 命令按邮件线程返回结果;如需单独返回每封邮件,请使用
gog gmail search命令。gog gmail messages search