oh-my-posh 配置自定义主题

  1. 效果展示
    展示为:➜ username on  D:/myworkspace/auto-epub ( master) (venv)  3.10.19
  1. 直接在 tokyonight_storm.omp.json 基础上修改

    javascript 复制代码
    {
      "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
      "console_title_template": " {{ .Folder }} :: {{if .Root}}Admin{{end}}",
      "palette": {
        "main-bg": "#24283b",
        "terminal-red": "#f7768e",
        "pistachio-green": "#9ece6a",
        "terminal-green": "#73daca",
        "terminal-yellow": "#e0af68",
        "terminal-blue": "#7aa2f7",
        "celeste-blue": "#b4f9f8",
        "light-sky-blue": "#7dcfff",
        "terminal-white": "#c0caf5",
        "white-blue": "#a9b1d6",
        "blue-bell": "#9aa5ce",
        "pastal-grey": "#cfc9c2",
        "terminal-magenta": "#bb9af7",
        "blue-black": "#565f89",
        "terminal-black": "#414868",
        "t-background": "p:main-bg"
      },
      "blocks": [
        {
          "alignment": "left",
          "segments": [
            {
              "type": "text",
              "style": "plain",
              "background": "transparent",
              "foreground": "p:terminal-blue",
              "template": "\u279c "
            },
            {
              "foreground": "#85b42e",
              "style": "plain",
              "template": "\ueb99 {{ .UserName }} on",
              "type": "session"
            },
            {
              "foreground": "p:terminal-magenta",
              "options": {
              "folder_separator_icon": "/",
              "style": "full"
            },
              "style": "plain",
              "template": " \uf07b {{ .Path }} ",
              "type": "path"
            },
            {
              "type": "git",
              "style": "plain",
              "foreground": "p:light-sky-blue",
              "foreground_templates": [
                "{{ if or (.Working.Changed) (.Staging.Changed) }}p:terminal-red{{ end }}",
                "{{ if and (gt .Ahead 0) (gt .Behind 0)}}p:light-sky-blue {{ end }}",
                "{{ if gt .Ahead 0 }}p:terminal-blue{{ end }}",
                "{{ if gt .Behind 0 }}p:celeste-blue{{ end }}"
              ],
              "template": "({{ .HEAD}})",
              "options": {
                "fetch_status": true,
                "branch_icon": "\ue725 "
              }
            },
            {
              "type": "status",
              "style": "plain",
              "foreground": "p:terminal-red",
              "template": " \uf00d"
            }
          ],
          "type": "prompt"
        },
        {
          "alignment": "right",
          "overflow": "hide",
          "segments": [
            {
              "type": "node",
              "style": "plain",
              "foreground": "p:pistachio-green",
              "template": "\ue718 {{ .Full }} "
            },
            {
              "type": "php",
              "style": "plain",
              "foreground": "p:terminal-yellow",
              "template": "\ue73d {{ .Full }} "
            },
            {
              "type": "python",
              "style": "plain",
              "foreground": "p:terminal-blue",
              "background": "transparent",
              "leading_diamond": "(",
              "trailing_diamond": ")",
              "template": "({{ .Venv }}) \uE235 {{ .Full }} "
            },
            {
              "type": "julia",
              "style": "plain",
              "foreground": "p:terminal-magenta",
              "template": "\uE624 {{ .Full }}"
            },
            {
              "type": "ruby",
              "style": "plain",
              "foreground": "p:terminal-red",
              "template": "\uE791 {{ .Full}}"
            },
            {
              "type": "go",
              "style": "plain",
              "foreground": "p:light-sky-blue",
              "template": "\uFCD1 {{ .Full}}"
            }
          ],
          "type": "prompt"
        },
        {
          "alignment": "left",
          "newline": true,
          "segments": [
            {
              "foreground": "transparent",
              "style": "plain",
              "template": "\u25b6",
              "type": "text"
            }
          ],
          "type": "prompt"
        }
      ],
      "secondary_prompt": {
        "background": "transparent",
        "foreground": "p:terminal-blue",
        "template": "\u279c "
      },
      "transient_prompt": {
        "background": "transparent",
        "foreground": "p:terminal-blue",
        "template": "\u279c "
      },
      "final_space": true,
      "version": 4,
      "terminal_background": "p:t-background"
    }
    1. 修改 Microsoft.PowerShell_profile.ps1

      bash 复制代码
      # 1. 给VSCode终端补全oh-my-posh的环境变量,防止识别不到
      $env:Path += ";$HOME\AppData\Local\Programs\oh-my-posh\bin"
      
      # 2. 避免与 Python 虚拟环境默认提示符冲突的关键设置,确保 oh-my-posh 能够完全控制提示符显示。
      $env:VIRTUAL_ENV_DISABLE_PROMPT = $true
      
      # 3. 加载oh-my-posh主题
      oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/tokyonight_storm.omp.json" | Invoke-Expression
相关推荐
weixin199701080162 小时前
《二手ERP对接闲鱼API:聚石塔强制入塔后的架构重构实录》(附Python源码)
python
小白快快跑哦2 小时前
python-字符串全解(六):正则表达式-转义与非转义
python·正则表达式·转义与非转义
IvanCodes7 小时前
Python 数据处理(十三):JSON、CSV 与数据序列化
开发语言·python
Patrick在香港8 小时前
Claude 工具调用返回空:8 次失败里只有 1 次状态码不对,其余全带 200
爬虫·python·api·claude·香港
Web3&Basketball9 小时前
CRM Agent 后训练实战:3 倍更少错误
python·架构·大模型·agent·推理
AIFQuant10 小时前
ETF行情API接入踩坑记:从报错到跑通的七个问题
python·金融·区块链·etf·基金
GPU实战笔记11 小时前
云端 Python 开发:JupyterLab 还是 VS Code Remote-SSH?
python·vs code·jupyterlab·remote-ssh·远程开发
2501_9159184111 小时前
iOS编程用什么软件好?主流工具Xcode、AppCode、CodeRunner与新兴快蝎对比
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程
狗狗狗狗狗乐啊11 小时前
搭一个 AI 对话工作台 AChat:从 0 到可用的完整记录(一)
python·react.js·ai编程
白猫不黑12 小时前
Python实现简易Web弱口令爆破与防护方案
python·web安全·计算机·网络安全·黑客·信息安全·渗透测试