category
type
status
date
slug
summary
tags
password
Property
Mar 15, 2023 03:55 AM
icon

效果预览

notion image
notion image

安装流程

安装PowerShell 7

  • 选择PowerShell 7的原因:在安装Oh My Posh的过程中产生的问题相比window自带版本的PowerShell问题更少,对Oh My Posh更加兼容。
  • 安装流程:无脑安装,把能选的框都勾选,疯狂下一步,Finish!

安装Windows Terminal

notion image

安装winget

在MicroSoft Store中即可安装
notion image

在PowerShell中安装Oh My Posh

  • 使用winget下载安装
  • 防止Windows杀毒进程误杀
ANTIVIRUS SOFTWARE
Due to frequent updates of Oh My Posh, Antivirus software occasionally flags it (false positive). To ensure Oh My Posh isn't blocked you can either report it to your favorite Antivirus software as false positive (e.g. Report a false positive/negative to Microsoft for analysis) or create an exclusion for it. Exclusions should be added with the full path to the executable, you can get it with the following command from a PowerShell prompt:

下载安装Oh My Posh需要的Nerd Font字体

  • 在Terminal中设置默认字体为CodeNewRoman Nerd Font Mono
notion image
编辑成功后直接保存后即可
编辑成功后直接保存后即可

在PowerShell中配置Oh My Posh

  • 显示你当前使用的终端类型
  • 编辑PowerShell配置文件
如果提示文件不存在则执行如下命令创建
最后在配置文件中加入如下内容后保存即可
👀ANTIVIRUS SOFTWARE
If adding an exception to your Antivirus software still blocks Oh My Posh for Windows, you can try using the below alternate line in your PowerShell profile. This is a drop-in replacement to the above call with Invoke-Expression. Tested with PowerShell 7.2.4 with Bitdefender Antivirus installed and requires NO exceptions for oh-my-posh.exe. Bitdefender blocks the calls to Invoke-Expression as malicious code and this alternate line skips the double calls:
重载配置文件使配置生效
  • 如果提示:无法加载文件C:\Users\xxx\Documents\WindowsPowerShell\profile.ps1,因为在此系统上禁止运行脚本 ,可以参考如下文章的解决方法:
  • 安装成功后重启Terminal就行了:
notion image

安装Terminal Icon

直接参考Terminal Icon官方repository提供的方法就行了【官方仓库是使用scoop安装的,官方也给出了scoop的安装方法】
Terminal-Icons
devblackopsUpdated Aug 30, 2023
  • 安装成功后,执行dir命令列出的文件都会自带图标了
notion image

切换主题

  • 方法:在$PROFILE目录下的Microsoft。PowerShell_profile.ps1中添加如下目标主题配置
notion image
  • 保存文件后在PowerShell中执行. $PROFILE即可生效。
  • 以下是我使用1_shell主题的效果
notion image

terminal使用小技巧

  • 快速在屏幕顶部呼出terminal
notion image
  • 去掉每次启动时,PowerShell都输出的ugly的版本提示信息
notion image

插件相关

安装NeoFetch用来显示电脑配置

即使已经按照了git,还是要用scoop按照git,因为neofetch会直接使用scoop安装的git
  • 如果在使用scoop中安装git提示找不到git,执行如下命令即可
最后执行scoop bucket list的结果如下:
notion image
重新执行scoop install git安装git即可
  • 成功安装neofetch的效果
notion image

安装posh-git插件

posh-git可以让Git指令用Tab键自动补全
  • 最后在$PROFILE配置文件中启用posh-git配置

安装插件Zlocation

Zlocation类似autojump或是zsh-z的插件,可以用关键字直接跳转到想去资料夹,比cd更高效。
  • 安装命令
  • 在$PROFILE中加入如下内容以启用ZLocation
  • 使用如下命令刷新配置使其生效
notion image
  • ZLocation的常用命令
    • 查看已知文件夹的位置:z
    • 进入包含对应字符串的文件夹,可用用Tab键来选择具体的文件夹:z doc
    • 回到之前的文件夹【这个功能真的方便,i了i了🤣】:z -

安装gsudo

可用用gsudo做到像Linux一样通过sudo命令获取系统管理员权限
  • 在PowerShell执行如下命令进行安装
  • 安装完成后,会询问是否用sudo来替代gsudo指令,个人建议选择Y
  • 配置一个使用gsudo提权的PowerShell终端
notion image
新建终端的主要配置改动如下:
notion image
之后只要打开这个终端就直接拥有系统管理员权限了!

我的最终配置文件

MongoDB事务Forza Horizon 5最强车:兰博基尼 SESTO ELEMENTO FE
  • Twikoo
  • Giscus