Windows Terminal的oh-my-posh配置方案

参考Tutorial: Set up a custom prompt for PowerShell or WSL with Oh My Posh

Install-Module oh-my-posh -Scope CurrentUser
notepad $PROFILE

在打开的配置文件中写入:

Import-Module oh-my-posh
Set-PoshPrompt -Theme powerlevel10k_rainbow

我的C:\Users\\Documents\WindowsPowerShell\Modules\oh-my-posh\themes\powerlevel_10k.omp.json文件改动后如下,对路径格式以及conda环境的显示进行了调整

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh3/main/themes/schema.json",
  "blocks": [
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "os",
          "style": "diamond",
          "foreground": "#000000",
          "background": "#d3d7cf",
          "leading_diamond": "╭─"
        },
        {
          "type": "path",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#e4e4e4",
          "background": "#3465a4",
          "properties": {
            "prefix": " \uF07C ",
            "home_icon": "~",
            "style": "folder"
          }
        },
        {
          "type": "git",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#000000",
          "background": "#4e9a06",
          "background_templates": [
            "{{ if or (.Working.Changed) (.Staging.Changed) }}#c4a000{{ end }}",
            "{{ if and (gt .Ahead 0) (gt .Behind 0) }}#f26d50{{ end }}",
            "{{ if gt .Ahead 0 }}#89d1dc{{ end }}",
            "{{ if gt .Behind 0 }}#4e9a06{{ end }}"
          ],
          "properties": {
            "branch_icon": "\uF126 ",
            "fetch_stash_count": true,
            "fetch_status": true,
            "fetch_upstream_icon": true,
            "template": "{{ .UpstreamIcon }}{{ .HEAD }}{{ .BranchStatus }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uF046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \uF692 {{ .StashCount }}{{ end }}"
          }
        }
      ]
    },
    {
      "type": "prompt",
      "alignment": "right",
      "segments": [
        {
          "type": "node",
          "style": "powerline",
          "powerline_symbol": "",
          "invert_powerline": true,
          "foreground": "#ffffff",
          "background": "#689f63",
          "properties": {
            "postfix": " \uF898 ",
            "display_version": true
          }
        },
        {
          "type": "go",
          "style": "powerline",
          "powerline_symbol": "",
          "invert_powerline": true,
          "foreground": "#111111",
          "background": "#00acd7",
          "properties": {
            "postfix": " \uE627 ",
            "display_version": true
          }
        },
        {
          "type": "julia",
          "style": "powerline",
          "powerline_symbol": "",
          "invert_powerline": true,
          "foreground": "#111111",
          "background": "#4063D8",
          "properties": {
            "postfix": " \uE624 ",
            "display_version": true
          }
        },
        {
          "type": "python",
          "style": "powerline",
          "powerline_symbol": "",
          "invert_powerline": true,
          "foreground": "#111111",
          "background": "#FFDE57",
          "properties": {
            "postfix": " \uE235 ",
	    "display_default": true,
            "display_mode": "context",
            "fetch_virtual_env": true,
            "template": "{{ .Venv }}"
          }
        },
        {
          "type": "ruby",
          "style": "powerline",
          "powerline_symbol": "",
          "invert_powerline": true,
          "foreground": "#ffffff",
          "background": "#AE1401",
          "properties": {
            "postfix": " \uE791 ",
            "display_version": true,
            "display_mode": "files"
          }
        },
        {
          "type": "azfunc",
          "style": "powerline",
          "powerline_symbol": "",
          "invert_powerline": true,
          "foreground": "#ffffff",
          "background": "#FEAC19",
          "properties": {
            "postfix": " \uf0e7",
            "display_version": false,
            "display_mode": "files"
          }
        },
        {
          "type": "aws",
          "style": "powerline",
          "powerline_symbol": "",
          "invert_powerline": true,
          "foreground": "#ffffff",
          "background_templates": [
            "{{if contains \"default\" .Profile}}#FFA400{{end}}",
            "{{if contains \"jan\" .Profile}}#f1184c{{end}}"
          ],
          "properties": {
            "postfix": " \uE7AD ",
            "display_default": false
          }
        },
        {
          "type": "root",
          "style": "powerline",
          "powerline_symbol": "",
          "invert_powerline": true,
          "foreground": "#111111",
          "background": "#ffff66",
          "properties": {
            "root_icon": "\uF0AD"
          }
        },
        {
          "type": "exit",
          "style": "powerline",
          "powerline_symbol": "",
          "invert_powerline": true,
          "foreground": "#d3d7cf",
          "background": "#000000",
          "background_templates": ["{{ if gt .Code 0 }}#cc2222{{ end }}"],
          "properties": {
            "always_enabled": true,
            "template": "{{ if gt .Code 0 }}{{ .Text }}{{ else }}✔{{ end }}"
          }
        },
        {
          "type": "time",
          "style": "diamond",
          "invert_powerline": true,
          "trailing_diamond": "\uE0B0─╮",
          "background": "#d3d7cf",
          "foreground": "#000000",
          "properties": {
            "postfix": " \uF017 "
          }
        }
      ]
    },
    {
      "type": "prompt",
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "type": "text",
          "style": "plain",
          "foreground": "#d3d7cf",
          "properties": {
            "prefix": "",
            "postfix": "",
            "text": "╰─"
          }
        }
      ]
    },
    {
      "type": "rprompt",
      "segments": [
        {
          "type": "text",
          "style": "plain",
          "foreground": "#d3d7cf",
          "properties": {
            "text": "─╯",
            "prefix": "",
            "postfix": ""
          }
        }
      ]
    }
  ],
  "final_space": true,
  "console_title": true,
  "console_title_style": "template",
  "console_title_template": "{{ .Folder }}"
}


你可能感兴趣的:(windows,windows,terminal)