""" 一次性脚本:更新 Kiro settings.json,将默认终端切换为 PowerShell 7 (pwsh.exe) """ import json import os import shutil settings_path = os.path.join( os.environ["APPDATA"], "Kiro", "User", "settings.json" ) # 备份 backup_path = settings_path + ".bak" shutil.copy2(settings_path, backup_path) print(f"已备份: {backup_path}") with open(settings_path, "r", encoding="utf-8") as f: settings = json.load(f) # 配置 PowerShell 7 为默认终端 profile settings["terminal.integrated.profiles.windows"] = { "PowerShell 7": { "path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe", "icon": "terminal-powershell", "args": ["-NoLogo"] }, "PowerShell 5": { "path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "icon": "terminal-powershell" }, "Command Prompt": { "path": "C:\\Windows\\System32\\cmd.exe", "icon": "terminal-cmd" } } settings["terminal.integrated.defaultProfile.windows"] = "PowerShell 7" with open(settings_path, "w", encoding="utf-8") as f: json.dump(settings, f, indent=4, ensure_ascii=False) print("已更新 Kiro settings.json:") print(" - 添加 PowerShell 7 profile") print(" - 默认终端设为 PowerShell 7 (pwsh.exe)") print("\n请重启 Kiro 使配置生效。")