Google 个人助理
通过 gog CLI 管理 Google Workspace 服务的综合技能。专为个人助理和幕僚长工作流设计,注重高效搜索、筛选和查询。
何时使用此技能
- 分类并处理电子邮件收件箱
- 安排会议并管理日历活动
- 查找多个日历的空闲时间
- 搜索并整理 Google Drive 文档
- 管理任务列表和待办事项
- 查找并管理联系人
- 在 Google Sheets 中读取和写入数据
- 导出 Docs、Slides 或 Sheets
- 设置专注时间或外出状态
先决条件
确保已安装并完成身份验证的 gog:
# Check installation
gog version
# Check authentication status
gog auth status
# Verify account access
gog people me
# Add a new account if needed
gog auth add [email protected] --services=all
快速入门
Gmail
# Search unread emails
gog gmail search "is:unread" --max=20
# Search from specific sender
gog gmail search "from:[email protected] newer_than:7d"
# Send an email
gog gmail send --to="[email protected]" --subject="Subject" --body="Message body"
# Reply to a thread
gog gmail send --reply-to-message-id=MESSAGE_ID --body="Reply text"
# Get message details
gog gmail get MESSAGE_ID
Calendar
# View today's events
gog calendar events --today
# View this week
gog calendar events --week
# Create an event with Google Meet
gog calendar create primary \
--summary="Team Sync" \
--from="2026-01-15T14:00:00-08:00" \
--to="2026-01-15T15:00:00-08:00" \
--attendees="[email protected],[email protected]" \
--with-meet
# Check availability
gog calendar freebusy "[email protected],[email protected]" \
--from="2026-01-15T09:00:00Z" --to="2026-01-15T17:00:00Z"
# Find scheduling conflicts
gog calendar conflicts --week
Drive
# List files in root
gog drive ls
# Search for documents
gog drive search "quarterly report"
# Download a file
gog drive download FILE_ID
# Upload a file
gog drive upload /path/to/file.pdf --parent=FOLDER_ID
# Get shareable URL
gog drive url FILE_ID
Tasks
# List task lists
gog tasks lists list
# View tasks in default list
gog tasks list @default
# Add a task
gog tasks add @default --title="Review report" --due="2026-01-15"
# Mark task complete
gog tasks done @default TASK_ID
Sheets
# Read a range
gog sheets get SPREADSHEET_ID "Sheet1!A1:D10"
# Update values
gog sheets update SPREADSHEET_ID "Sheet1!A1" "Value1" "Value2"
# Append a row
gog sheets append SPREADSHEET_ID "Sheet1!A:D" "Col1" "Col2" "Col3" "Col4"
Gmail 搜索语法
Gmail 搜索功能强大。以下是常用运算符:
发件人和收件人
状态和标签
| 运算符 | 示例 | 描述 |
|---|
is:unread | is:unread | 未读邮件 |
is:read | is:read | 已读邮件 |
is:starred | is:starred | 已加星标的邮件 |
is:important | is:important | 标记为重要的邮件 |
is:snoozed | is:snoozed | 已延后处理的邮件 |
label: | label:work | 带有指定标签 |
in:inbox | in:inbox | 位于收件箱 |
in:sent | in:sent | 位于已发送邮件 |
in:drafts | in:drafts | 位于草稿 |
in:trash | in:trash | 位于垃圾箱 |
in:spam | in:spam | 位于垃圾邮件 |
in:anywhere | in:anywhere | 所有邮件,包括垃圾邮件和垃圾箱中的邮件 |
内容和主题
| 运算符 | 示例 | 描述 |
|---|
subject: | subject:urgent | 主题包含指定词语 |
"exact phrase" | "quarterly report" | 精确短语匹配 |
has:attachment | has:attachment | 带有附件 |
filename: | filename:pdf | 附件文件名/类型 |
filename: | filename:report.xlsx | 指定文件名 |
日期和时间
| 运算符 | 示例 | 描述 |
|---|
newer_than: | newer_than:7d | 最近 N 天内 |
older_than: | older_than:1y | 早于 N 年 |
after: | after:2026/01/01 | 指定日期之后 |
before: | before:2026/12/31 | 指定日期之前 |
newer_than/older_than 的单位:d(天)、m(月)、y(年)
大小
| 运算符 | 示例 | 描述 |
|---|
larger: | larger:5M | 大于指定大小 |
smaller: | smaller:100K | 小于指定大小 |
单位:K(KB)、M(MB)
类别
| 运算符 | 示例 | 描述 |
|---|
category:primary | category:primary | 主要收件箱 |
category:social | category:social | 社交类别 |
category:promotions | category:promotions | 推广邮件 |
category:updates | category:updates | 更新 |
category:forums | category:forums | 论坛 |
布尔运算符
| 运算符 | 示例 | 描述 |
|---|
AND(或空格) | from:alice subject:report | 同时满足两个条件 |
OR | from:alice OR from:bob | 满足任一条件 |
-(NOT) | -category:promotions | 排除指定条件 |
() | (from:alice OR from:bob) is:unread | 分组 |
{} | {from:alice from:bob} | OR 简写 |
查询示例
# Unread from VIPs this week
gog gmail search "is:unread from:([email protected] OR [email protected]) newer_than:7d"
# Large attachments
gog gmail search "has:attachment larger:10M"
# Urgent subjects excluding promotions
gog gmail search "subject:(urgent OR asap OR EOD) -category:promotions is:unread"
# Contracts from legal team
gog gmail search "from:[email protected] subject:contract has:attachment filename:pdf"
# All messages in a thread (use thread ID from search results)
gog gmail thread get THREAD_ID
完整的运算符参考请参阅 references/gmail-search-syntax.md。
Drive 搜索语法
Drive 搜索使用查询语言来精确查找文件:
基本运算符
| 运算符 | 示例 | 描述 |
|---|
name contains | name contains 'report' | 文件名包含 |
fullText contains | fullText contains 'budget' | 搜索内容 |
mimeType = | mimeType = 'application/pdf' | 文件类型 |
日期筛选条件
| 运算符 | 示例 | 描述 |
|---|
modifiedTime > | modifiedTime > '2026-01-01' | 修改时间晚于 |
modifiedTime < | modifiedTime < '2026-01-01' | 修改时间早于 |
createdTime > | createdTime > '2026-01-01' | 创建时间晚于 |
viewedByMeTime > | viewedByMeTime > '2026-01-01' | 查看时间晚于 |
所有权与共享
| 运算符 | 示例 | 描述 |
|---|
'email' in owners | 'me' in owners | 由用户拥有 |
'email' in writers | '[email protected]' in writers | 用户可以编辑 |
'email' in readers | '[email protected]' in readers | 用户可以查看 |
sharedWithMe | sharedWithMe | 与你共享 |
属性
| 运算符 | 示例 | 描述 |
|---|
starred | starred | 已加星标的文件 |
trashed = false | trashed = false | 不在回收站中 |
'folderId' in parents | 'FOLDER_ID' in parents | 位于指定文件夹中 |
常见 MIME 类型
| 类型 | MIME 类型 |
|---|
| Google 文档 | application/vnd.google-apps.document |
| Google 表格 | application/vnd.google-apps.spreadsheet |
| Google 幻灯片 | application/vnd.google-apps.presentation |
| Google 表单 | application/vnd.google-apps.form |
| 文件夹 | application/vnd.google-apps.folder |
| PDF | application/pdf |
| Word | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
| Excel | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
布尔运算符
and - 两个条件都必须匹配
or - 任一条件匹配
not - 否定条件
查询示例
# Recent docs mentioning Q4
gog drive search "fullText contains 'Q4' and modifiedTime > '2026-01-01'"
# All spreadsheets shared with me
gog drive search "sharedWithMe and mimeType = 'application/vnd.google-apps.spreadsheet'"
# PDFs I own
gog drive search "'me' in owners and mimeType = 'application/pdf'"
# Files modified this week
gog drive search "modifiedTime > '2026-01-03'"
# Documents in specific folder
gog drive ls --parent=FOLDER_ID
# Starred presentations
gog drive search "starred and mimeType = 'application/vnd.google-apps.presentation'"
完整的查询参考请参阅 references/drive-search-syntax.md。
PA/CoS 工作流
每日早间收件箱筛选
# 1. Check unread counts by label
gog gmail labels list --json | jq '.[] | select(.messagesUnread > 0) | {name, unread: .messagesUnread}'
# 2. Review unread from priority senders
gog gmail search "is:unread from:([email protected] OR [email protected])" --max=20
# 3. Check for urgent subjects
gog gmail search "is:unread subject:(urgent OR asap OR EOD OR \"action required\")" --max=10
# 4. Review threads needing response (excludes noise)
gog gmail search "is:unread in:inbox -category:updates -category:promotions -category:social" --max=30
# 5. Check for emails with attachments requiring action
gog gmail search "is:unread has:attachment newer_than:2d" --max=15
安排会议
# 1. Find availability for attendees
gog calendar freebusy "[email protected],[email protected]" \
--from="2026-01-15T09:00:00-08:00" \
--to="2026-01-15T17:00:00-08:00"
# 2. Check your own conflicts
gog calendar conflicts --days=7
# 3. Create the meeting
gog calendar create primary \
--summary="Project Kickoff" \
--from="2026-01-15T14:00:00-08:00" \
--to="2026-01-15T15:00:00-08:00" \
--attendees="[email protected],[email protected]" \
--description="Agenda:\n1. Project overview\n2. Timeline review\n3. Action items" \
--location="Conference Room A" \
--with-meet \
--reminder="popup:15m"
# 4. Send follow-up email with details
gog gmail send \
--to="[email protected],[email protected]" \
--subject="Meeting Scheduled: Project Kickoff - Jan 15 at 2pm" \
--body="Hi team,
I've scheduled our project kickoff meeting for Wednesday, January 15th at 2:00 PM.
Location: Conference Room A (Google Meet link in calendar invite)
Agenda:
1. Project overview
2. Timeline review
3. Action items
Please let me know if you have any conflicts.
Best regards"
每周日历准备
# 1. View the week ahead
gog calendar events --week
# 2. Check all calendars for the week
gog calendar events --week --all
# 3. Find and resolve conflicts
gog calendar conflicts --week
# 4. Check team availability (for group)
gog calendar team [email protected] --week
# 5. Block focus time
gog calendar focus-time \
--from="2026-01-16T09:00:00-08:00" \
--to="2026-01-16T12:00:00-08:00"
# 6. Set out of office (if needed)
gog calendar out-of-office \
--from="2026-01-20" \
--to="2026-01-21" \
--summary="Out of office - personal day"
# 7. Set working location
gog calendar working-location \
--from="2026-01-17" \
--to="2026-01-17" \
--type="home"
文档搜索与整理
# Find all docs from a project
gog drive search "fullText contains 'Project Alpha'"
# List recent docs you created
gog drive search "'me' in owners and modifiedTime > '2026-01-01'" --max=50
# Find docs shared by specific person
gog drive search "'[email protected]' in writers"
# Find presentation decks
gog drive search "mimeType = 'application/vnd.google-apps.presentation' and modifiedTime > '2025-10-01'"
# Download a doc as PDF
gog docs export DOC_ID --format=pdf --output="./report.pdf"
# Read doc contents (plain text for quick review)
gog docs cat DOC_ID
# Export spreadsheet as Excel
gog sheets export SPREADSHEET_ID --format=xlsx --output="./data.xlsx"
# Get shareable link
gog drive url FILE_ID
gog drive share FILE_ID --role=reader --type=anyone
每日任务管理
# 1. List all task lists
gog tasks lists list
# 2. View all tasks in default list
gog tasks list @default
# 3. View tasks due today
gog tasks list @default --due-max="$(date -u +%Y-%m-%dT23:59:59Z)"
# 4. Add a new task with due date
gog tasks add @default \
--title="Review Q4 financials" \
--due="2026-01-15" \
--notes="Check revenue projections and expense reports"
# 5. Complete a task
gog tasks done @default TASK_ID
# 6. Reopen a completed task
gog tasks undo @default TASK_ID
# 7. Delete a task
gog tasks delete @default TASK_ID
# 8. Clear all completed tasks
gog tasks clear @default
联系人查询
# Search for a contact
gog contacts search "John Smith"
# List all contacts
gog contacts list --max=100
# Get contact details
gog contacts get RESOURCE_NAME
# Create a new contact
gog contacts create \
--given="Jane" \
--family="Doe" \
--email="[email protected]" \
--phone="+1-555-123-4567"
# Search directory (Workspace)
gog contacts directory search "engineering"
更多工作流示例请参阅 references/common-workflows.md。
命令参考
Gmail 命令
| 命令 | 描述 | 主要标志 |
|---|
gmail search <query> | 搜索会话 | --max、--oldest、--page |
gmail get <messageId> | 获取邮件内容 | --format=full|metadata|raw |
gmail send | 发送邮件 | --to、--cc、--bcc、--subject、--body、--attach |
gmail thread get <id> | 获取完整会话 | - |
gmail thread modify <id> | 修改会话标签 | --add-labels、--remove-labels |
gmail labels list | 列出所有标签 | - |
gmail labels get <name> | 获取标签详情 | - |
gmail labels modify <ids> | 批量修改标签 | --add、--remove |
gmail attachment <msgId> <attId> | 下载附件 | - |
gmail url <threadId> | 获取 Gmail 网页 URL | - |
gmail batch delete <ids> | 批量删除 | - |
gmail drafts list | 列出草稿 | - |
gmail drafts create | 创建草稿 | 与 send 使用相同的标志 |
日历命令
| 命令 | 描述 | 关键标志 |
|---|
calendar calendars | 列出日历 | - |
calendar events [calId] | 列出活动 | --from、--to、--today、--week、--all |
calendar event <calId> <eventId> | 获取活动详情 | - |
calendar create <calId> | 创建活动 | --summary、--from、--to、--attendees、--with-meet |
calendar update <calId> <eventId> | 更新活动 | 同创建活动 |
calendar delete <calId> <eventId> | 删除活动 | - |
calendar freebusy <calendars> | 检查空闲情况 | --from、--to |
calendar conflicts | 查找冲突 | --week、--days |
calendar search <query> | 搜索活动 | - |
calendar respond <calId> <eventId> | 回复邀请 | --status=accepted|declined|tentative |
calendar focus-time | 创建专注时段 | --from、--to |
calendar out-of-office | 设置不在办公室 | --from、--to |
calendar working-location | 设置工作地点 | --from、--to、--type |
calendar team <groupEmail> | 查看团队日历 | - |
Drive 命令
| 命令 | 描述 | 关键标志 |
|---|
drive ls | 列出文件 | --parent |
drive search <query> | 全文搜索 | --max |
drive get <fileId> | 获取文件元数据 | - |
drive download <fileId> | 下载文件 | --output |
drive upload <path> | 上传文件 | --name、--parent |
drive mkdir <name> | 创建文件夹 | --parent |
drive delete <fileId> | 删除(移至回收站) | - |
drive move <fileId> | 移动文件 | --parent |
drive rename <fileId> <name> | 重命名文件 | - |
drive share <fileId> | 分享文件 | --role、--type、--email |
drive unshare <fileId> <permId> | 移除权限 | - |
drive permissions <fileId> | 列出权限 | - |
drive url <fileId> | 获取网页 URL | - |
drive copy <fileId> <name> | 复制文件 | - |
Sheets 命令
| 命令 | 描述 | 关键标志 |
|---|
sheets get <id> <range> | 读取值 | - |
sheets update <id> <range> [vals] | 更新值 | --input=RAW|USER_ENTERED |
sheets append <id> <range> [vals] | 追加行 | --input |
sheets clear <id> <range> | 清除值 | - |
sheets metadata <id> | 获取电子表格信息 | - |
sheets create <title> | 创建电子表格 | - |
sheets copy <id> <title> | 复制电子表格 | - |
sheets export <id> | 导出 | --format=pdf|xlsx|csv |
Docs 命令
| 命令 | 描述 | 关键标志 |
|---|
docs cat <docId> | 以纯文本形式输出 | - |
docs export <docId> | 导出文档 | --format=pdf|docx|txt |
docs info <docId> | 获取元数据 | - |
docs create <title> | 创建文档 | - |
docs copy <docId> <title> | 复制文档 | - |
Slides 命令
| 命令 | 描述 | 关键标志 |
|---|
slides export <id> | 导出演示文稿 | --format=pdf|pptx |
slides info <id> | 获取元数据 | - |
slides create <title> | 创建演示文稿 | - |
slides copy <id> <title> | 复制演示文稿 | - |
Tasks 命令
| 命令 | 描述 | 关键标志 |
|---|
tasks lists list | 列出任务列表 | - |
tasks list <listId> | 列出任务 | --due-min、--due-max、--show-completed |
tasks add <listId> | 添加任务 | --title、--due、--notes |
tasks update <listId> <taskId> | 更新任务 | 同添加任务 |
tasks done <listId> <taskId> | 标记为已完成 | - |
tasks undo <listId> <taskId> | 标记为未完成 | - |
tasks delete <listId> <taskId> | 删除任务 | - |
tasks clear <listId> | 清除已完成任务 | - |
联系人命令
| 命令 | 说明 | 主要标志 |
|---|
contacts search <query> | 搜索联系人 | - |
contacts list | 列出所有联系人 | --max |
contacts get <resourceName> | 获取联系人 | - |
contacts create | 创建联系人 | --given、--family、--email、--phone |
contacts update <resourceName> | 更新联系人 | 与创建相同 |
contacts delete <resourceName> | 删除联系人 | - |
contacts directory search | 搜索目录 | - |
群组命令
| 命令 | 说明 | 主要标志 |
|---|
groups list | 列出你的群组 | - |
groups members <groupEmail> | 列出群组成员 | - |
人员命令
| 命令 | 说明 | 主要标志 |
|---|
people me | 显示你的个人资料 | - |
全局标志
所有 gog 命令均支持以下标志:
| 标志 | 说明 |
|---|
--json | 输出 JSON(最适合脚本处理或通过管道传递给 jq) |
--plain | 输出 TSV,不使用颜色(适用于脚本和解析) |
--account=EMAIL | 使用指定账户(支持多个账户) |
--force | 跳过确认提示 |
--no-input | 从不显示提示,直接失败(适用于 CI/自动化) |
--verbose | 输出详细日志以便调试 |
--color=<auto|always|never> | 控制颜色输出 |
多账户用法
# Use specific account for a command
gog gmail search "is:unread" [email protected]
# List available accounts
gog auth list
用于脚本的 JSON 输出
# Get unread count for inbox
gog gmail labels get INBOX --json | jq '.messagesUnread'
# Extract event IDs from today
gog calendar events --today --json | jq '.[].id'
# List file IDs from search
gog drive search "budget" --json | jq '.[].id'
# Process email subjects
gog gmail search "is:unread" --json | jq '.[].snippet'
最佳实践
高效搜索
- 先缩小范围,再逐步扩大 - 从具体查询开始,结果过多时再添加筛选条件
- 使用日期筛选条件 -
newer_than: 可大幅减少无关结果
- 组合运算符 -
is:unread from:boss newer_than:7d 比浏览更高效
- 使用
--max - 探索时限制结果数量:--max=10
日历管理
- 与他人安排会议前,务必检查 freebusy
- 远程会议使用
--with-meet,以自动创建视频链接
- 设置提醒 - 重要会议可使用
--reminder="popup:15m"
- 主动安排专注时间,保障深度工作
云端硬盘整理
- 使用文件夹 ID - 保存常用文件夹 ID,以便快速访问
- 按内容搜索 -
fullText contains 即使文件名不明确,也能找到文档
- 按 MIME 类型筛选 - 缩小到特定文档类型
- 尽早导出 - 将重要文档下载为 PDF,以便离线访问
自动化提示
- 使用
--json 编写脚本 - 使用 jq 解析
- 简单脚本使用
--plain - 以制表符分隔,不使用颜色
- 在 CI 中使用
--no-input - 防止因提示而卡住
- 保存 ID - 以便重复使用日历、文件夹和任务列表 ID
参考文件