| 学习路线指引(点击解锁) | 知识定位 | 人群定位 |
|---|---|---|
| 🧡 Python实战微信订餐小程序 🧡 | 进阶级 | 本课程是python flask+微信小程序的完美结合,从项目搭建到腾讯云部署上线,打造一个全栈订餐系统。 |
| 💛Python量化交易实战💛 | 入门级 | 手把手带你打造一个易扩展、更安全、效率更高的量化交易系统 |
本文旨在快速让你进行美化,少踩一些坑,原文出自我的博客:prettier-windows-terminal-with-oh-my-posh
为了同 iterm2 下的 oh-my-zsh 保持基本一致,博主用的是 aliens 主题+一些自定义配置调整,最终效果如下,你也可以根据自己需要进行细调

v7.87.07.2.3,(最新为 7.2.4)1. 安装时请关闭杀毒软件、各类管家,否则写入注册表时会报错。
2. 有条件的请挂代理,因为源文件在 git 上。
3. 全程在 powershell ,管理员模式 下进行。
可直接在 microsoft store 中搜索安装。这里不赘述。
如其名,为了在 windows 下使用 sudo 命令,需要安装该包。
git 地址:https://gerardog.github.io/gsudo/docs/install
可以直接在 powershell 中执行以下命令进行安装:
winget install gerardog.gsudo
# 示例:以管理员身份启动 powershell
gsudo powershell.exe
如果你觉得 gsudo 不够直观,希望用 sudo,可以通过以下方式重命名:
Set-Alias 'sudo' 'gsudo'
官方:https://ohmyposh.dev/
git 地址:https://github.com/jandedobbeleer/oh-my-posh
winget install oh-my-posh
oh-my-posh 的不少主题都是依赖于该字体,否则部分 icon 会乱码,建议安装。

在 windows terminal 的设置中,打开JSON文件:

编辑配置:

sudo 别名的话,这里用 gsudo。
创建 powershell 配置文件:
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
用记事本打开配置文件
notepad $PROFILE
在记事本中录入以下指令
oh-my-posh init pwsh --config ~/.leon.omp.theme.json | Invoke-Expression
习惯了 iterm2 中 CMD+D,SHIFT+CMD+D 来拆分窗口,很庆幸 windows terminal 已经提供了快捷键修改,且针对的就是拆分窗口,直接设置即可,如下:

{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"background": "#61AFEF",
"foreground": "#ffffff",
"leading\_diamond": "\ue0b6",
"style": "diamond",
"template": "{{ .HostName }} ",
"trailing\_diamond": "\ue0b0",
"type": "session"
},
{
"background": "#C678DD",
"foreground": "#ffffff",
"powerline\_symbol": "\ue0b0",
"properties": {
"style": "full"
},
"style": "powerline",
"template": " {{ .Path }} ",
"type": "path"
},
{
"background": "#95ffa4",
"foreground": "#193549",
"powerline\_symbol": "\ue0b0",
"style": "powerline",
"template": " {{ .HEAD }} ",
"type": "git"
},
{
"background": "#FF6471",
"foreground": "#ffffff",
"leading\_diamond": "\ue0b0",
"style": "diamond",
"template": " {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }} ",
"trailing\_diamond": "\ue0b4",
"type": "python"
}
],
"type": "prompt"
}
],
"final\_space": true,
"version": 2
}