Windows Terminal 配置指南

Windows Terminal 配置指南

打造现代化的 Windows 终端体验

📋 目录

🚀 软件安装

必需软件

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

⚙️ 基础配置

设置默认终端

  1. 打开 Windows Terminal
  2. Ctrl + , 打开设置
  3. 在左侧选择 "启动"
  4. 将默认配置文件设置为 "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 }

📚 相关资源

官方文档

替代方案

实用链接

🔄 更新维护

定期更新

bash 复制代码
# 更新所有 winget 包
winget upgrade --all

# 更新 Starship
winget upgrade Starship.Starship

备份配置

建议定期备份以下文件:

  • $PROFILE - PowerShell 配置文件
  • ~/.config/starshell.toml - Starship 配置
  • Windows Terminal 设置文件
相关推荐
小爱同学_1 天前
一次面试让我重新认识了 Cursor
前端·面试·程序员
彼日花1 天前
前端新人30天:从手足无措到融入团队
前端·程序员
你的人类朋友2 天前
【操作系统】说说 x86 和 x64
后端·程序员·操作系统
希赛网2 天前
华为 HCIA-Datacom 备考:VRP 通用路由平台原理-实操
华为·网络工程师·命令行·路由配置·vrp
AI大模型2 天前
构建可用于生产环境的 RAG 智能体:开发者完整指南
程序员·llm·agent
SimonKing3 天前
GitHub 标星 370k!免费编程资源大合集,从此自学不花一分钱
java·后端·程序员
韦德说3 天前
副业整整一周年:从产品交付到市场运营的真实经验分享
程序员·开源·产品
AI绘画哇哒哒3 天前
实战:SQL统一访问200+数据源,构建企业级智能检索与RAG系统(下)
人工智能·sql·深度学习·学习·ai·程序员·大模型
AI大模型3 天前
别再把RAG当记忆:这5个开源引擎让AI真正会记住
程序员·llm·agent
大模型教程3 天前
彻底搞懂大模型“预训练”和“微调”
程序员·llm·agent