Windows 常用设置
终端 - Windows Terminal
Windows Store 安装
包管理器 - Winget
Windows Store 安装
Winget 替换源
powershell
winget source remove winget
winget source add winget https://mirrors.ustc.edu.cn/winget-sourceShell - PowerShell 7
PowerShell 7 安装
powershell
winget install --id Microsoft.PowerShell --source winget美化
Oh My Posh
powershell
winget install JanDeDobbeleer.OhMyPosh --source wingetNerd Font
powershell
Install-PSResource -Name NerdFonts
Import-Module -Name NerdFonts
Install-NerdFont -Name JetBrainsMono然后在终端设置中选择字体为 JetBrainsMono Nerd Font Mono
激活 Oh My Posh 创建空配置文件
powershell
New-Item -Path $PROFILE -Type File -Force然后编辑配置文件
powershell
notepad $PROFILE在文件中添加以下内容
powershell
oh-my-posh init pwsh | Invoke-Expression
# 或者
oh-my-posh init pwsh --config ~/tokyonight_storm.omp.json | Invoke-ExpressionOh My Posh 主题列表: https://ohmyposh.dev/docs/themes
常用包安装
powershell
# winfetch
Install-Script winfetch
# get-posh
Install-Module -Name posh-git -Scope CurrentUser
# eza 现代版ls
winget install eza-community.eza配置文件
Microsoft.PowerShell_profile.ps1
powershell
oh-my-posh init pwsh --config ~/tokyonight_storm.omp.json | Invoke-Expression
# ps-read-line
Import-Module PSReadLine
# posh-git
Import-Module posh-git
# 移除 ls alias
Remove-Item Alias:ls -Force
# 设置预测文本来源为历史记录
Set-PSReadLineOption -PredictionSource History
# 每次回溯输入历史,光标定位于输入内容末尾
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
# 设置 Tab 为菜单补全和 Intellisense
Set-PSReadLineKeyHandler -Key "Tab" -Function MenuComplete
# 设置 Ctrl+d 为退出 PowerShell
Set-PSReadlineKeyHandler -Key "Ctrl+d" -Function ViExit
# 设置 Ctrl+z 为撤销
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo
# 设置向上键为后向搜索历史记录
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
# 设置向下键为前向搜索历史纪录
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
# rm -rf alias
function rmrf ($dir_path){
Remove-Item -Recurse -Force $dir_path
}
# mv alias
function mv($file_path, $des_name) {
Move-Item -Path $file_path -Destination $des_name
}
# ls alias
function ls {
eza --group-directories-first --icons --color=auto @args
}
# ll alias
function ll {
eza -l --icons --group-directories-first @args
}相关链接: