Files
BlueRoseNote/07-Other/AI/AI Agent/UnrealEngine/Windows Terminal Claude Code 快捷方式.md

100 lines
3.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
tags:
- windows
- claude-code
- tooling
created: 2026-05-31
---
# Windows Terminal 快捷方式启动 Claude Code 项目
## 原理
桌面快捷方式(`.lnk`)先启动 Windows Terminal再由 Windows Terminal 的 Profile 定义工作目录和启动命令,最终自动进入指定项目的 Claude Code 会话。
```
桌面快捷方式 (.lnk)
→ wt.exe -p "ProfileName"
→ Windows Terminal 读取 settings.json 中对应 Profile
→ cmd.exe /k "cd 项目目录 && claude --dangerously-skip-permissions"
→ Claude Code 启动,进入交互会话
```
## 两层结构
### 1. Windows Terminal Profilesettings.json
位置:`%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json`
每个项目一个 Profile例如
```json
{
"guid": "{30e2bee9-2311-49a4-9798-fe50e1fb872e}",
"name": "AIDM",
"commandline": "cmd.exe /k \"cd /d D:\\MatrixTA\\AIGameDev\\AIDM && set CLAUDE_CODE_DISABLE_TERMINAL_TITLE=1 && claude --dangerously-skip-permissions\"",
"startingDirectory": "D:\\MatrixTA\\AIGameDev\\AIDM",
"tabColor": "#16A34A",
"suppressApplicationTitle": true,
"icon": "🎮",
"hidden": false
}
```
字段说明:
| 字段 | 作用 |
|------|------|
| `guid` | 唯一标识,内部匹配用 |
| `name` | 显示在下拉菜单和标签页标题,也是 `-p` 参数的匹配值 |
| `commandline` | 实际执行的命令,通过 `cmd.exe /k` 保证窗口保持 |
| `startingDirectory` | 初始工作目录 |
| `tabColor` | 标签页颜色,方便区分项目 |
| `suppressApplicationTitle` | 禁止应用修改终端标题 |
| `icon` | 标签页图标emoji |
### 2. 桌面快捷方式(.lnk
PowerShell 创建方式:
```powershell
$shell = New-Object -ComObject WScript.Shell
$desktop = [Environment]::GetFolderPath('Desktop')
$shortcut = $shell.CreateShortcut("$desktop\AIDM.lnk")
$shortcut.TargetPath = "C:\Users\loujiajie\AppData\Local\Microsoft\WindowsApps\wt.exe"
$shortcut.Arguments = '-p "AIDM"'
$shortcut.WorkingDirectory = "D:\MatrixTA\AIGameDev\AIDM"
$shortcut.Save()
```
字段说明:
| 属性 | 值 | 说明 |
|------|-----|------|
| `TargetPath` | `wt.exe` 完整路径 | Windows Terminal 可执行文件 |
| `Arguments` | `-p "ProfileName"` | 匹配 settings.json 中 Profile 的 `name` 字段 |
| `WorkingDirectory` | 项目目录 | 与 Profile 中的 `startingDirectory` 一致 |
## 新增项目的步骤
> [!note] 完整流程
> 1. 在 `settings.json` 的 `profiles.list` 数组中添加新 Profile
> 2. 生成新的 GUIDPowerShell: `[guid]::NewGuid()`
> 3. 创建桌面 `.lnk` 快捷方式指向 `wt.exe -p "新Profile名"`
## 已有项目 Profile 一览
| 项目 | Tab 颜色 | 图标 | 目录 |
|------|----------|------|------|
| CharacterMaker | `#1E3CB4` (蓝) | 🔥 | `D:\AI\Website\CharacterMaker` |
| AIDM | `#16A34A` (绿) | 🎮 | `D:\MatrixTA\AIGameDev\AIDM` |
| POPODocs | `#0078D7` (蓝) | 📄 | `D:\AI\Skill\MatrixAITA-POPODocs-Skill` |
| NeteaseAITA_Artlib | `#808080` (灰) | 🎨 | `D:\AI\Website\NeteaseAITA_Artlib` |
## 关键细节
- **`cmd.exe /k`**:执行完后续命令后保持窗口不关闭,用户可继续交互
- **`--dangerously-skip-permissions`**:跳过 Claude Code 的权限提示,适合本地开发
- **`CLAUDE_CODE_DISABLE_TERMINAL_TITLE=1`**:禁止 Claude Code 修改终端标题,保持 Profile 名称显示
- **`suppressApplicationTitle: true`**:配合上一条,双重保障标题不被覆盖
- **GUID 必须唯一**:每个 Profile 的 `guid` 用于内部匹配,`name` 用于 `-p` 参数匹配