windows命令行美化 - windows terminal、oh-my-posh

在这里插入图片描述

安装工具 - 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

  1. 不花里胡哨
  2. 总能列出有用信息
  3. ⚡因为要列出系统资源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字体

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

骆言

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值