• 28/06 cập nhật đăng ký đăng nhập qua Google & Facebook

Cách tự đặt tên task terminal Claude Code

TenHoshi

Administrator
Staff member
Trusted Uploader
Cài sang máy Mac khác

Cách 1: Dán vào Claude Code trên máy kia

Bật tên tab terminal tự đổi theo task cho mọi dự án. Làm đúng các bước sau:

1. Tìm file settings cấp User của các editor có trên máy (bỏ qua file không tồn tại):
- ~/Library/Application Support/Code/User/settings.json
- ~/Library/Application Support/Cursor/User/settings.json
- ~/Library/Application Support/Code - Insiders/User/settings.json
- ~/Library/Application Support/Windsurf/User/settings.json
2. Đọc từng file trước khi sửa. Thêm (hoặc ghi đè nếu đã có) 2 key này, giữ nguyên mọi key khác:
"terminal.integrated.tabs.title": "${sequence}",
"terminal.integrated.tabs.description": "${cwdFolder}"
Nếu editor đã cài mà chưa có file settings.json thì tạo file mới chỉ chứa 2 key trên.
3. Sau khi sửa, kiểm tra lại từng file vẫn là JSON hợp lệ và đọc ra 2 giá trị vừa ghi.
4. Kiểm tra ~/.claude/settings.json không có biến CLAUDE_CODE_DISABLE_TERMINAL_TITLE. Nếu có thì báo mình, đừng tự xoá.
5. Báo lại: đã sửa file nào và kết quả kiểm tra.

Cách 2: Dán thẳng vào Terminal, không cần Claude

Code:
python3 - <<'EOF'
import json, os
base = os.path.expanduser("~/Library/Application Support")
for app in ["Code", "Cursor", "Code - Insiders", "Windsurf"]:
d = os.path.join(base, app, "User")
if not os.path.isdir(d):
continue
p = os.path.join(d, "settings.json")
try:
s = json.load(open(p)) if os.path.exists(p) and open(p).read().strip() else {}
except Exception as e:
print(f"BỎ QUA {app}: settings.json có comment/lỗi ({e}) – sửa tay"); continue
s["terminal.integrated.tabs.title"] = "${sequence}"
s["terminal.integrated.tabs.description"] = "${cwdFolder}"
json.dump(s, open(p, "w"), indent=4, ensure_ascii=False)
print(f"OK {app}: {p}")
EOF



Nếu file settings có comment //, lệnh này sẽ báo "BỎ QUA" và không sửa file đó. Gặp trường hợp này thì dùng Cách 1. Lệnh này cũng viết lại cả file theo định dạng chuẩn, thụt lề 4 dấu cách. Các thiết lập cũ vẫn giữ nguyên.

Làm xong thì mở terminal mới trong VS Code hoặc Cursor rồi chạy claude. Tab sẽ hiện tên task từ lượt trả lời thứ hai.

Terminal khác:
- iTerm2: vào Profiles → General → Title, chọn "Session Name" và bật "Applications in terminal may change the title".
- Terminal.app, Warp, WezTerm: tự nhận tên, không cần chỉnh.
 

Guest Post 2022

Top