Windows Terminal 设置

Windows Terminal 设置
1. 安装starship
-
安装方式(windows):
-
Winget:
winget install --id Starship.Starship -
配置方式:
- 首先在 powershell 中输入
$PROFILE,会自动打开 powershell 的配置文件。 - 在配置文件中输入
Invoke-Expression (&starship init powershell)并保存即可。
- 首先在 powershell 中输入
-
配置文件绝对路径:
C:\Users\{username}\.config\starship.toml(如果没有自己建一个即可) -
预设网站: Presets | Starship
-
2. Windows PowerShell tab以当前目录作为名称(和starship会冲突)
配置方式:
- 首先在 powershell 中输入
$PROFILE,会自动打开 powershell 的配置文件。 - 然后添加下面内容
# tab显示当前目录
# Windows Terminal 设置 添加 "suppressApplicationTitle" 选项,并将其设置为 false
function Test-Administrator
{
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
# Set prompt and title
Function Prompt {
$administrator = Test-Administrator
$location = $executionContext.SessionState.Path.CurrentLocation
$filename = Split-Path $location -leaf
if ($administrator) {
# 管理员启动会添加一个 #
$host.UI.RawUI.WindowTitle = "# $filename"
"PS $location $('>' * ($nestedPromptLevel + 1)) "
} else {
$host.UI.RawUI.WindowTitle = "$filename"
"PS $pwd>"
}
}
3. 设置Cluade Code 中Shift+Enter 换行
{
"actions": [
{
"command": {
"action": "sendInput",
"input": "u001bn"
},
"id": "User.sendInput.FE9C254"
}
],
"keybindings": [
{
"id": "User.sendInput.FE9C254",
"keys": "shift+enter"
}
]
}
4. 设置字体
需要先下载 JetBrains Mono字体
安装方式(windows):
-
进入解压后的
fonts/ttf文件夹。全选所有字体文件(
Ctrl + A)。核心操作: 右键点击选中的文件,选择 “为所有用户安装” (Install for all users)。
注意:如果直接双击安装,有时只会安装在当前用户路径下,部分应用可能读取不到。
{
"profiles": {
"defaults": {
"font": {
"face": "JetBrains Mono",
"size": 12,
"weight": "normal"
}
}
}
5. 设置Tab 颜色
设置:
-
$profiles.list.找到对应终端。添加
"tabColor": "#4e1bb4"{ "profiles": { "list": [ { "commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "hidden": false, "name": "Windows PowerShell", "tabColor": "#4e1bb4" }, { "commandline": "%SystemRoot%\\System32\\cmd.exe", "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", "hidden": false, "name": "命令提示符", "tabColor": "#4fd065" } ] } }
6. Power Shell 设置代理
前提:不想使用全局代理,但是Codex官方访问必须要代理,Codex无法像Claude Code一样在配置文件中配置代理,所以给Power Shell 设置代理
设置:
- Windows Terminal 添加配置命名
code - 命令行, 配置
%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoExit -File "C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profile-code.ps1"选择配置路径,不与其他的冲突。 Microsoft.PowerShell_profile-code.ps1配置
# 设置 HTTP 和 HTTPS 代理
$env:HTTP_PROXY = "http://127.0.0.1:7897"
$env:HTTPS_PROXY = "http://127.0.0.1:7897"
# 可选:如果你希望在启动时看到代理已开启的提示
Write-Host "Proxy configuration loaded: 127.0.0.1:7897" -ForegroundColor Green