Windows Terminal 配置指南

·
2026-08-03 00:16:41

Windows Terminal 配置指南

打造现代化的 Windows 终端体验

📋 目录

软件安装

基础配置

[PowerShell 配置](#PowerShell 配置 "#powershell-%E9%85%8D%E7%BD%AE")

主题美化

实用技巧

相关资源

🚀 软件安装

必需软件

bash

复制代码

# 安装 PowerShell 7

winget install Microsoft.PowerShell

# 安装 Starship 提示符

winget install --id Starship.Starship

# 安装系统信息工具

winget install fastfetch

# 安装 Neovim 编辑器

winget install Neovim.Neovim

可选软件

bash

复制代码

# 安装 Git

winget install Git.Git

# 安装 Node.js

winget install OpenJS.NodeJS

# 安装 Python

winget install Python.Python.3.11

⚙️ 基础配置

设置默认终端

打开 Windows Terminal

按 Ctrl + , 打开设置

在左侧选择 "启动"

将默认配置文件设置为 "PowerShell"

启用 Tab 补全

参考官方文档:在 shell 中使用 Tab 键补全

🔧 PowerShell 配置

编辑配置文件

powershell

复制代码

# 打开 PowerShell 配置文件

nvim $PROFILE

# 或者使用记事本

notepad $PROFILE

基础配置示例

powershell

复制代码

# 初始化 Starship 提示符

Invoke-Expression (&starship init powershell)

# 设置别名

Set-Alias vi nvim

Set-Alias ll ls

Set-Alias g git

# 设置默认编码

[Console]::OutputEncoding = [System.Text.Encoding]::UTF8

# 启用历史记录

Set-PSReadLineOption -HistorySavePath "$env:USERPROFILE\.powershell_history"

# 启用预测文本

Set-PSReadLineOption -PredictionSource History

🎨 主题美化

Starship 配置

创建 ~/.config/starship.toml 文件:

toml

复制代码

# 获取配置架构

format = """

[┌─](bold green)$username$hostname$directory$git_branch$git_status

[└─](bold green)$character"""

[character]

success_symbol = "[➜](bold green)"

error_symbol = "[✗](bold red)"

[directory]

style = "blue bold"

truncation_length = 3

truncation_symbol = ".../"

[git_branch]

symbol = " "

style = "bold purple"

[git_status]

style = "bold red"

ahead = "⇡\${count}"

behind = "⇣\${count}"

diverged = "⇕⇡\${ahead_count}⇣\${behind_count}"

untracked = "?"

modified = "!"

staged = "+"

renamed = ">>"

deleted = "✘"

Windows Terminal 主题

推荐使用以下主题:

Dracula - 经典深色主题

One Dark Pro - 现代化主题

Material Theme - Material Design 风格

💡 实用技巧

快捷键

快捷键

功能

Ctrl + Shift + T

新建标签页

Ctrl + Shift + W

关闭标签页

Ctrl + Shift + D

垂直分割

Ctrl + Shift + E

水平分割

Alt + ←/→

切换标签页

Ctrl + Shift + ←/→

调整分割大小

常用命令

powershell

复制代码

# 查看系统信息

fastfetch

# 快速打开常用目录

function code { Set-Location "C:\Users\$env:USERNAME\Documents\code" }

function docs { Set-Location "C:\Users\$env:USERNAME\Documents" }

# Git 快捷命令

function gs { git status }

function ga { git add . }

function gc { git commit -m $args[0] }

function gp { git push }

📚 相关资源

官方文档

Windows Terminal 官方文档

PowerShell 官方文档

Starship 官方文档

替代方案

Oh My Posh - 另一个强大的提示符定制工具

Powerlevel10k - Zsh 主题(适用于 WSL)

实用链接

Windows Terminal 技巧和窍门

PowerShell 最佳实践

🔄 更新维护

定期更新

bash

复制代码

# 更新所有 winget 包

winget upgrade --all

# 更新 Starship

winget upgrade Starship.Starship

备份配置

建议定期备份以下文件:

$PROFILE - PowerShell 配置文件

~/.config/starshell.toml - Starship 配置

Windows Terminal 设置文件