最好事先将就系统里边的.ssh
文件夹备份。
.gitconfig
这两个就可以了
配置Terminal
安装字体
https://github.com/ryanoasis/nerd-fonts/releases
选择JetBrainMono
安装PowerShell7
https://github.com/PowerShell/PowerShell/releases
选择win-x64.msi
安装时,全部勾选对勾
安装Window Terminal
在微软应用商店安装即可
安装PowerShell插件
Install-Module -Name PSReadLine -AllowPrerelease -Force -Verbose
Install-Module posh-git -Scope CurrentUser -Verbose
Install-Module oh-my-posh -Scope CurrentUser -Verbose
|
安装过程中可能很慢,可以在cmd中启用http proxy
# 设置本地代理的端口号 7890 为你实际的端口号 set http_proxy=http://127.0.0.1:7890 set https_proxy=http://127.0.0.1:7890
# 如果需要恢复本地代理(清除代理) set http_proxy= set https_proxy=
|
配置 PowerShell
打开 PowerShell7,输入命令:
Set-ExecutionPolicy RemoteSigned
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force } notepad $PROFILE
|
之前可能没有这个文件,点击是
,新建这个文件
编辑配置文件,需要的配置项取消命令前面的注释,不需要的配置项使用 “#” 注释:
把下边的配置直接粘进去,保存。
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme half-life
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo
Set-PSReadlineKeyHandler -Key "Ctrl+d" -Function ViExit
Set-PSReadlineKeyHandler -Key Tab -Function Complete
Set-PSReadlineKeyHandler -Key "Ctrl+d" -Function ViExit
function ListDirectory { (Get-ChildItem).Name Write-Host("") }
Set-Alias -Name ls -Value ListDirectory
Set-Alias -Name ll -Value Get-ChildItem
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
|
打开一次Windows Terminal,等待导入一些东西。
修改Windows Terminal的json配置文件
当你使用别的字体的时候,可能会因为名称不正确导致无法找到对应的字体,可以在记事本中找一下字体在系统中的名称,再在这里输入字体的名字。
{ "acrylicOpacity": 0.20000000000000001, "colorScheme": "Homebrew", "fontFace": "JetBrainsMono NF", "fontSize": 11, "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", "hidden": false, "historySize": 9001, "name": "PowerShell", "padding": "5, 5, 20, 25", "snapOnInput": true, "source": "Windows.Terminal.PowershellCore", "useAcrylic": false },
|
颜色配置(来源于参考文章)
{ "name": "Homebrew", "black": "#000000", "red": "#FC5275", "green": "#00a600", "yellow": "#999900", "blue": "#6666e9", "purple": "#b200b2", "cyan": "#00a6b2", "white": "#bfbfbf", "brightBlack": "#666666", "brightRed": "#e50000", "brightGreen": "#00d900", "brightYellow": "#e5e500", "brightBlue": "#0000ff", "brightPurple": "#e500e5", "brightCyan": "#00e5e5", "brightWhite": "#e5e5e5", "background": "#283033", "foreground": "#00ff00" },
|
参考文章
Windows Terminal 完美配置 PowerShell 7.1
字体选择