美文网首页
powershell配置(5) - ohmyposh3

powershell配置(5) - ohmyposh3

作者: 洗洗睡吧i | 来源:发表于2021-04-01 21:36 被阅读0次

1.安装

以scoop安装oh-my-posh3。

scoop install oh-my-posh3

2. 配置文件

新建、修改配置文件,运行:

if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
code $PROFILE

加入以下内容:

chcp 65001
Set-PSReadLineOption -PredictionSource History  # 默认是 None

oh-my-posh init pwsh --config ~\scoop\persist\oh-my-posh\themes\yo.omp.json | Invoke-Expression

ref: (https://ohmyposh.dev/docs/installation)[https://ohmyposh.dev/docs/installation]

3. 自定义ys主题

  • 打开主题文件,路径: ~\scoop\persist\oh-my-posh\themes\yo.omp.json
{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "left",
      "segments": [
        {
          "foreground": "red",
          "properties": {
            "template": "{{ if .Root }}% {{ else }}<blue># </>{{end}}"
          },
          "style": "plain",
          "type": "text"
        },
        {
          "foreground": "cyan",
          "properties": {
            "template": "{{ .UserName }}<white> @ </><green>{{ .HostName }}</>"
          },
          "style": "plain",
          "type": "session"
        },
        {
          "foreground": "lightYellow",
          "properties": {
            "style": "short",
            "template": "<white> in </>{{ .Path }} "
          },
          "style": "plain",
          "type": "path"
        },
        {
          "foreground": "cyan",
          "properties": {
            "fetch_status": true,
            "template": []
          },
          "style": "plain",
          "type": "git"
        },
        {
          "foreground": "white",
          "properties": {
            "template": "[{{ .CurrentDate | date .Format }}]",
            "time_format": "15:04:05"
          },
          "style": "plain",
          "type": "time"
        },
        {
          "foreground": "red",
          "properties": {
            "template": " C: {{ .Code }}"
          },
          "style": "plain",
          "type": "exit"
        }
      ],
      "type": "prompt"
    },
    {
      "type": "newline"
    },
    {
      "alignment": "left",
      "segments": [
        {
          "foreground": "red",
          "properties": {
            "template": "$"
          },
          "style": "plain",
          "type": "text"
        }
      ],
      "type": "prompt"
    }
  ],
  "console_title": true,
  "console_title_style": "template",
  "console_title_template": "{{.User}} :: {{.Folder}} :: {{.Shell}}",
  "final_space": true,
  "version": 1
}



done!

相关文章

网友评论

      本文标题:powershell配置(5) - ohmyposh3

      本文链接:https://www.haomeiwen.com/subject/eeotkltx.html