文章目录
安装工具 - scoop - (非必须)
除了更新powershell,其他都可以通过scoop下载,管理
如果不使用scoop,可以使用使用windows store
使用scoop参考 - https://lawsssscat.blog.csdn.net/article/details/107671202
更新powershell - (非必须)
github: https://github.com/PowerShell/PowerShell
从github下载安装包安装即可
如果使用scoop进行包管理,使用旧的powershell会有奇奇怪怪的问题
这是随系统自带的ps。默认在C:\Windows\System32\WindowsPowerShell\v1.0
这是安装的最新ps 2023年3月26日
默认在C:\Program Files\PowerShell\7\
⚠安装新的之后,没必要删除旧的。哪要用新的,在哪的配置文件中配置即可。microsoft出品一般自动指向新powershell位置的,所以一般不需要手动指向。
安装windows terminal
github: https://github.com/microsoft/terminal
如果通过scoop安装
scoop bucket add extras
scoop install windows-terminal
❯ scoop info windows-terminal
Name : windows-terminal
Description : The new Windows Terminal, and the original Windows console host - all in the same place!
Version : 1.16.10261.0
Bucket : extras
Website : https://github.com/microsoft/terminal
License : MIT
Updated at : 2023/1/28 4:26:24
Updated by : github-actions[bot]
Installed : 1.16.10261.0
Binaries : WindowsTerminal.exe | wt.exe
Shortcuts : Windows Terminal
Suggestions : extras/vcredist2022
Notes : Add Windows Terminal as a context menu option by running `reg import "<root>\install-context.reg"`
可见,有多标签管理和更多详细的设置,而且默认使用了新的powershell
进一步说明
下面步骤根据这里进行(截图记录)
https://learn.microsoft.com/en-us/windows/terminal/tutorials/custom-prompt-setup
安装字体
Nerd Font - https://www.nerdfonts.com/font-downloads
微软那篇文章建议:
CaskaydiaCove Nerd Font
安装oh-my-posh
https://ohmyposh.dev/docs/installation/windows
https://ohmyposh.dev/docs/installation/customize
scoop install oh-my-posh
> scoop info oh-my-posh
Name : oh-my-posh
Description : A prompt theme engine for any shell
Version : 14.19.1
Bucket : main
Website : https://ohmyposh.dev
License : MIT
Updated at : 2023/3/25 8:34:29
Updated by : github-actions[bot]
Installed : 14.19.1
Binaries : oh-my-posh.exe
Environment : POSH_THEMES_PATH = <root>\themes
Notes : Refer to 'https://ohmyposh.dev/docs/installation/prompt' for shell specific configurations.
> scoop info oh-my-posh -v
Name : oh-my-posh
Description : A prompt theme engine for any shell
Version : 14.19.1
Bucket : main
Website : https://ohmyposh.dev
License : MIT (https://spdx.org/licenses/MIT.html)
Updated at : 2023/3/25 8:34:29
Updated by : github-actions[bot]
Manifest : C:\Users\pc\scoop\buckets\main\bucket\oh-my-posh.json
Installed : C:\Users\pc\scoop\apps\oh-my-posh\14.19.1
Installed size : Current version: 21.4 MB
Cached downloads: 28.2 MB
Total: 49.6 MB
Binaries : oh-my-posh.exe
Environment : POSH_THEMES_PATH = C:\Users\pc\scoop\apps\oh-my-posh\current\themes
Notes : Refer to 'https://ohmyposh.dev/docs/installation/prompt' for shell specific configurations.
⚠从官网上,使用json安装的oh-my-posh似乎不遵循scoop目录规范
为powershell添加oh-my-posh使用
> vim $PROFILE
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\paradox.omp.json" | Invoke-Expression
主题
配置项解释
https://ohmyposh.dev/docs/configuration/overview
主题
https://ohmyposh.dev/docs/themes
更换主题,更换配置文件名即可
推荐的主题
tokyo
- 不花里胡哨
- 总能列出有用信息
- ⚡因为要列出系统资源cpu、内存用量,快速输出时,相比其他主题会更慢
# https://ohmyposh.dev/docs/themes
# $env:POSH_THEMES_MYSELECT='ys'
$env:POSH_THEMES_MYSELECT='tokyo'
# $env:POSH_THEMES_MYSELECT='thecyberden'
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\$env:POSH_THEMES_MYSELECT.omp.json" | Invoke-Expression
1_shell —— 同tokyo,显示内容全,且回看历史记录更简洁
stelbent.minimal —— 不关心cpu、内存,可以用这个 【🔥正在用🔥】
stelbent-compact.minimal
通过oh-my-posh安装字体
oh-my-posh font install
其他
powershell设置字体
如果powershell不设置字体,那么在使用oh-my-posh的主题时会出现乱码
如果只在windows terminal中设置了字体,只在windows terminal中生效,powershell中不会生效
vscode设置powershell字体
vscode内部没法集成windows terminal,所以默认集成的时powershell,所以powershell乱码问题要解决
powershell设置字体看上面,这里记录vscode内部如何设置powershell字体