gog

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

gog

gog

Use
gog
for Gmail/Calendar/Drive/Contacts/Sheets/Docs. Requires OAuth setup.
Setup (once)
  • gog auth credentials /path/to/client_secret.json
  • gog auth add you@gmail.com --services gmail,calendar,drive,contacts,docs,sheets
  • gog 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
    gog calendar colors
    to see all available event colors (IDs 1-11)
  • Add colors to events with
    --event-color <id>
    flag
  • Event color IDs (from
    gog calendar colors
    output):
    • 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. Use
    --body-file
    for multi-paragraph messages (or
    --body-file -
    for stdin).
  • Same
    --body-file
    pattern works for drafts and replies.
  • --body
    does not unescape
    \n
    . If you need inline newlines, use a heredoc or
    $'Line 1\n\nLine 2'
    .
  • Use
    --body-html
    only when you need rich formatting.
  • HTML tags:
    <p>
    for paragraphs,
    <br>
    for line breaks,
    <strong>
    for bold,
    <em>
    for italic,
    <a href="url">
    for links,
    <ul>
    /
    <li>
    for lists.
  • 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
    GOG_ACCOUNT=you@gmail.com
    to avoid repeating
    --account
    .
  • For scripting, prefer
    --json
    plus
    --no-input
    .
  • Sheets values can be passed via
    --values-json
    (recommended) or as inline rows.
  • Docs supports export/cat/copy. In-place edits require a Docs API client (not in gog).
  • Confirm before sending mail or creating events.
  • gog gmail search
    returns one row per thread; use
    gog gmail messages search
    when you need every individual email returned separately.
使用
gog
操作Gmail、Calendar、Drive、Contacts、Sheets和Docs。需要完成OAuth配置。
首次配置
  • gog auth credentials /path/to/client_secret.json
  • gog auth add you@gmail.com --services gmail,calendar,drive,contacts,docs,sheets
  • gog 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>
日历颜色设置
  • 使用
    gog calendar colors
    查看所有可用的事件颜色(ID范围1-11)
  • 通过
    --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
    参数不会解析转义字符
    \n
    。如果需要换行,请使用here文档或
    $'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
    命令。