PowerShell 美化(谁不想要一个好看的终端呢)

111 阅读1分钟

@[TOC](PowerShell 美化)

花里胡哨的折腾(bushi 多种主题任君挑选

安装powershell

地址:github.com/PowerShell/… 在这里插入图片描述在这里插入图片描述

本文主要使用 Oh My Posh 进行美化 地址:ohmyposh.dev/

Scoop 安装

# 启用 PowerShell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

# 安装
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
# 或
iwr -useb get.scoop.sh | iex

检查是否安装成功

scoop help

参考链接:blog.csdn.net/luoyooi/art…

Oh My Posh

Oh My Posh 建议使用 Windows Terminal,可以在 MicroSoft Store 进行下载

安装

打开 PowerShell,执行下边的命令

scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json

字体设置

Oh My Posh 大部分的主题要求使用 Nerd Font 字体,我们可以使用以下方式选择想要安装的字体。以管理员身份打开 PowerShell 执行以下代码

oh-my-posh font install

由于网络原因可能下载失败,可以直接点击链接下载对应的字体安装 字体安装好之后,打开 Windows Terminal 配置文件(CTRL + SHIFT + ,),在 profiles.defaults选项下添加如下代码,以 FiraCode字体为例

"font":
{
    "face": "FiraCode NF"
}

应用主题

地址:ohmyposh.dev/docs/themes 在 PowerShell 中执行以下命令,打开配置文件:

notepad $PROFILE

然后添加:

oh-my-posh init pwsh | Invoke-Expression

下载所有主题到本地

Get-PoshThemes

重新打开配置文件,配置主题,修改主题只需要更换 xxx.omp.json 即可

notepad $PROFILE
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/jandedobbeleer.omp.json" | Invoke-Expression

查看主题保存目录:

$env:POSH_THEMES_PATH

加一张喵子的背景 在这里插入图片描述