最近一直在使用Windows开发,所以需要配置一下终端。
在Windows store中安装Terminal,因为这个版本的界面看起来比较舒服,如下。

然后就是安装oh-my-posh & posh-git
1 2 3
| Install-Module posh-git -Scope CurrentUser # posh-git
winget install JanDeDobbeleer.OhMyPosh # 新版oh-my-posh安装方式
|
可以在这里下载主题,推荐iterm2.omp.json
主题
完成之后打开终端配置
输入下面代码
1 2 3 4 5 6 7 8 9 10 11 12
| Import-Module posh-git Import-Module PSReadLine
oh-my-posh init pwsh --config <本机路径>\iterm2.omp.json | Invoke-Expression
Set-PSReadLineOption -PredictionSource History Set-PSReadlineKeyHandler -Key Tab -Function Complete Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
|
配置完成之后可能会有乱码,需要安装字体,我安装的是FiraCode Nerd Font,下载解压之后,把ttf中的字体全选,然后右击为所有用户安装即可。
然后在terminal设置中打开JSON文件,在profiles
下的defaults
写入如下配置即可
1 2 3 4 5 6 7 8 9 10
| "font": { "face": "FiraCode NF", "size": 14, "weight": "extra-light" //文字宽度,可设置加粗 }, "useAcrylic": true, // 启用毛玻璃 "colorScheme": "One Half Dark", //主题名字 "cursorShape": "vintage", //光标形状 "startingDirectory": "C://workspace//", //起始目录 "antialiasingMode": "cleartype" //消除文字锯齿
|