terminal-title

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Terminal Title

终端标题

Overview

概述

Automatically sets descriptive terminal window titles based on the task Claude is working on. Essential for developers running multiple Claude Code instances who need to quickly identify which terminal is handling which task.
根据Claude正在处理的任务自动设置描述性的终端窗口标题。对于运行多个Claude Code实例、需要快速识别哪个终端处理哪个任务的开发者来说,这是必不可少的功能。

When to Use

使用时机

Always trigger this skill:
  • At the start of every new Claude Code session (after receiving the first user prompt)
  • When switching to a substantially different task (e.g., from "API Integration" to "Database Migration")
Trigger on task switches like these:
  • Switching from frontend work to backend work
  • Moving from debugging to new feature development
  • Changing from one module/component to a completely different one
  • Starting work on a different part of the system (e.g., from auth to payments)
Do NOT trigger for:
  • Follow-up questions about the same task ("Can you add a comment to that function?")
  • Small refinements to current work ("Make it blue instead of red")
  • Debugging the same feature you just built
  • Clarifications ("What did you mean by X?")
  • Iterating on the same component or module
  • Mid-task status updates or progress checks
务必触发此功能的场景:
  • 每个新Claude Code会话开始时(收到用户第一个提示后)
  • 切换到完全不同的任务时(例如,从"API集成"切换到"数据库迁移")
此类任务切换需触发:
  • 从前端工作切换到后端工作
  • 从调试切换到新功能开发
  • 从一个模块/组件切换到完全不同的模块/组件
  • 开始处理系统的不同部分(例如,从认证模块切换到支付模块)
请勿触发的场景:
  • 关于同一任务的后续问题("你能给那个函数加个注释吗?")
  • 对当前工作的小调整("把它改成蓝色而不是红色")
  • 调试刚构建的同一功能
  • 澄清疑问("你说的X是什么意思?")
  • 对同一组件或模块进行迭代
  • 任务进行中的状态更新或进度检查

How It Works

工作原理

  1. Extract Task Summary: Analyze the user's prompt to identify the high-level task
  2. Generate Title: Create a concise, descriptive title (max 40 characters)
  3. Set Title: Execute the
    scripts/set_title.sh
    script with the generated title
  4. No Confirmation Needed: This happens automatically in the background
  1. 提取任务摘要:分析用户的提示以识别高级任务
  2. 生成标题:创建一个简洁、具有描述性的标题(最多40个字符)
  3. 设置标题:执行
    scripts/set_title.sh
    脚本并传入生成的标题
  4. 无需确认:此操作在后台自动完成

Title Format Guidelines

标题格式规范

Good titles:
  • "API Integration: Auth Flow"
  • "Fix: Login Bug"
  • "DB Migration: Users Table"
  • "Build: Dashboard UI"
  • "Refactor: Payment Module"
Displayed as (with automatic folder prefix):
  • my-project | API Integration: Auth Flow
  • my-project | Fix: Login Bug
Bad titles:
  • Too long: "Implementing the new authentication system with OAuth2.0 support" (exceeds 40 chars)
  • Too generic: "Working" or "Coding"
  • Too verbose: "The user wants me to help them with..."
Format pattern:
[Action/Category]: [Specific Focus]
The script automatically prefixes titles with the current directory name (usually the repo name) for easy identification across multiple terminals.
Keep titles concise, actionable, and immediately recognizable.
好的标题示例:
  • "API集成:认证流程"
  • "修复:登录Bug"
  • "数据库迁移:用户表"
  • "构建:仪表盘UI"
  • "重构:支付模块"
显示效果(带自动文件夹前缀):
  • my-project | API集成:认证流程
  • my-project | 修复:登录Bug
不好的标题示例:
  • 过长:"实现支持OAuth2.0的新认证系统"(超过40个字符)
  • 过于通用:"工作中"或"编码中"
  • 过于冗长:"用户希望我帮助他们完成..."
格式模板:
[操作/分类]: [具体焦点]
脚本会自动在标题前添加当前目录名称(通常是仓库名称),以便在多个终端中轻松识别。
请保持标题简洁、可操作且易于快速识别。

Common Mistakes to Avoid

需避免的常见错误

❌ Too Verbose:
  • Bad: "Working on implementing the user authentication system with JWT tokens"
  • Good: "Build: JWT Auth"
❌ Too Vague:
  • Bad: "Code stuff"
  • Bad: "Working"
  • Good: "Refactor: API Layer"
❌ Including System Information:
  • Bad: "john-macbook-pro: Debug app"
  • Bad: "/Users/john/project: Build feature"
  • Good: "Debug: App Issues"
❌ Using Complete Sentences:
  • Bad: "I am working on the dashboard component"
  • Good: "Build: Dashboard UI"
❌ 过于冗长:
  • 错误示例:"开发带有JWT令牌的用户认证系统"
  • 正确示例:"构建:JWT认证"
❌ 过于模糊:
  • 错误示例:"编码相关"
  • 错误示例:"工作中"
  • 正确示例:"重构:API层"
❌ 包含系统信息:
  • 错误示例:"john-macbook-pro: 调试应用"
  • 错误示例:"/Users/john/project: 构建功能"
  • 正确示例:"调试:应用问题"
❌ 使用完整句子:
  • 错误示例:"我正在开发仪表盘组件"
  • 正确示例:"构建:仪表盘UI"

Implementation

实现方式

Execute the title script:
bash
bash scripts/set_title.sh "Your Title Here"
Example workflow:
bash
undefined
执行标题脚本:
bash
bash scripts/set_title.sh "你的标题内容"
示例工作流:
bash
undefined

User asks: "Help me debug the authentication flow in the API"

用户提问:"帮我调试API中的认证流程"

bash scripts/set_title.sh "Debug: Auth API Flow"
bash scripts/set_title.sh "调试:认证API流程"

User asks: "Create a React component for the user profile page"

用户提问:"为用户资料页创建一个React组件"

bash scripts/set_title.sh "Build: User Profile UI"
bash scripts/set_title.sh "构建:用户资料UI"

User asks: "Write tests for the payment processing module"

用户提问:"为支付处理模块编写测试"

bash scripts/set_title.sh "Test: Payment Module"
undefined
bash scripts/set_title.sh "测试:支付模块"
undefined

Script Details

脚本详情

The
scripts/set_title.sh
script uses ANSI escape sequences to set the terminal title. It's compatible with:
  • macOS Terminal
  • iTerm2
  • Alacritty
  • Most modern terminal emulators (xterm, rxvt, screen, tmux)
The script accepts a single argument (the title string) and exits silently if no title is provided (fail-safe behavior).
scripts/set_title.sh
脚本使用ANSI转义序列来设置终端标题。它兼容以下终端:
  • macOS Terminal
  • iTerm2
  • Alacritty
  • 大多数现代终端模拟器(xterm, rxvt, screen, tmux)
该脚本接受一个参数(标题字符串),如果未提供标题则会静默退出(故障安全行为)。

Automatic Directory Prefix

自动目录前缀

The script automatically prefixes all titles with the current directory name (usually the repo/project name). This makes it easy to identify which project each terminal is working on:
my-project | Build: Dashboard UI
another-repo | Debug: Auth API
脚本会自动在所有标题前添加当前目录名称(通常是仓库/项目名称)。这使得识别每个终端正在处理哪个项目变得容易:
my-project | 构建:仪表盘UI
another-repo | 调试:认证API

Optional Custom Prefix

可选自定义前缀

Users can optionally add an additional custom prefix by setting the
CLAUDE_TITLE_PREFIX
environment variable:
bash
export CLAUDE_TITLE_PREFIX="🤖"
This produces titles like:
🤖 my-project | Build: Dashboard UI
Note: You don't need to check for these variables or modify your behavior. The script handles this automatically.
用户可以通过设置
CLAUDE_TITLE_PREFIX
环境变量来添加额外的自定义前缀:
bash
export CLAUDE_TITLE_PREFIX="🤖"
生成的标题类似:
🤖 my-project | 构建:仪表盘UI
注意: 你无需检查这些变量或修改操作方式。脚本会自动处理这部分逻辑。",