WindowsTerminal中oh-my-posh样式的cmd、git-bash、cmder配置参数

C:\Users\root\Documents\WindowsPowerShell中写如下内容

bash 复制代码
Import-Module posh-git # 引入 posh-git
Import-Module oh-my-posh # 引入 oh-my-posh
Import-Module -Name Terminal-Icons  # 引入文件图标库
Import-Module PSReadLine # 历史命令联想
# 设置主题
Set-PoshPrompt -Theme D:\software\oh-my-posh\themes\kushal.omp.json
# Set-PSReadLineOption -PredictionSource History # 设置预测文本来源为历史记录
# Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete # 设置 Tab 键,命令行自动补全和提示
# Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete # 设置 Ctrl+d 为菜单补全和 Intellisense
# Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward # 设置向上键为后向搜索历史记录
# Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward # 设置向下键为前向搜索历史纪录


# 设置预测文本来源为历史记录 
Set-PSReadLineOption -PredictionSource History 
# 设置 Tab 为菜单补全和 Intellisense 
Set-PSReadlineKeyHandler -Key Tab -Function Complete # 设置 Tab 键补全
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete # 设置 Ctrl+d 为菜单补全和 Intellisense
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo # 设置 Ctrl+z 为撤销

Set-PSReadLineKeyHandler -Key UpArrow -ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchBackward()
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
} # 设置向上键为后向搜索历史记录,并将光标移动到行尾

Set-PSReadLineKeyHandler -Key DownArrow -ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchForward()
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
} # 设置向下键为前向搜索历史纪录,并将光标移动到行尾

D:**\clink\on-my-posh.lua中写如下内容

bash 复制代码
load(io.popen('oh-my-posh init cmd --config D:/software/oh-my-posh/themes/kushal.omp.json'):read("*a"))()

配置文件kushal.omp.json放入C:\Users\root\目录下

C:\Users\root.profile中写如下内容

bash 复制代码
eval "$(oh-my-posh --init --shell bash --config ~/kushal.omp.json)"

要加 -i -l


要加cmd.exe /k


要取消勾选仅显示等宽字体


亮色配色

kushal.omp.json,修改自kushal.omp.json

bash 复制代码
{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "console_title_template": "{{ if .Root }}root @ {{ end }}{{ .Shell }} in {{ .Folder }}",
  "blocks": [
    {
      "alignment": "left",
      "segments": [
        {
          "background": "#575656",
          "foreground": "#d3e4ff",
          "leading_diamond": "\ue0b2",
          "properties": {
            "alpine": "\uf300",
            "arch": "\uf303",
            "centos": "\uf304",
            "debian": "\uf306",
            "elementary": "\uf309",
            "fedora": "\uf30a",
            "gentoo": "\uf30d",
            "linux": "\ue712",
            "macos": "\ue711",
            "manjaro": "\uf312",
            "mint": "\uf30f",
            "opensuse": "\uf314",
            "raspbian": "\uf315",
            "ubuntu": "\uf31c",
            "windows": "\ue70f"
          },
          "style": "diamond",
          "template": " {{ if .WSL }}\ue712 on {{ end }}{{ .Icon }} ",
          "type": "os"
        },
        {
          "background": "#00C7FC",
          "foreground": "#011627",
          "powerline_symbol": "\ue0b0",
          "style": "powerline",
          "template": " \uf489 {{ .Name }} ",
          "type": "shell"
        },
        {
          "background": "#EF541C",
          "foreground": "#d3e4ff",
          "powerline_symbol": "\ue0b0",
          "style": "powerline",
          "template": " \uf09c admin ",
          "type": "root"
        },
        {
          "type": "cmake",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#E8EAEE",
          "background": "#1E9748",
          "template": " \ue61e \ue61d cmake {{ .Full }} "
        },
        {
          "type": "python",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "display_mode": "context"
          },
          "foreground": "#011627",
          "background": "#FFDE57",
          "template": " \ue73c {{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }} "
        },
        {
          "type": "go",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#ffffff",
          "background": "#7FD5EA",
          "template": " \u202d\ue626 {{ .Full }} "
        },
        {
          "type": "rust",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#193549",
          "background": "#99908A",
          "template": " \ue7a8 {{ .Full }} "
        },
        {
          "background": "#1BD4CD",
          "background_templates": [
            "{{ if or (.Working.Changed) (.Staging.Changed) }}#16B1AC{{ end }}",
            "{{ if and (gt .Ahead 0) (gt .Behind 0) }}#16B1AC{{ end }}",
            "{{ if gt .Ahead 0 }}#B787D7{{ end }}",
            "{{ if gt .Behind 0 }}#B787D7{{ end }}"
          ],
          "foreground": "#011627",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "branch_icon": "\ue725 ",
            "fetch_stash_count": true,
            "fetch_status": true,
            "fetch_upstream_icon": true,
            "fetch_worktree_count": true
          },
          "style": "powerline",
          "template": " {{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }}<#CAEBE1> \uf046 {{ .Staging.String }}</>{{ end }}{{ if gt .StashCount 0 }} \ueb4b {{ .StashCount }}{{ end }} ",
          "type": "git"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "right",
      "segments": [
        {
          "background": "#03DED3",
          "background_templates": [
            "{{ if gt .Code 0 }}#E44141{{ end }}"
          ],
          "foreground": "#414141",
          "foreground_templates": [
            "{{ if gt .Code 0 }}#7aabfc{{ end }}"
          ],
          "leading_diamond": "\ue0b6",
          "properties": {
            "always_enabled": true
          },
          "style": "diamond",
          "template": " {{ if gt .Code 0 }}\uf00d{{ else }}\uf00c{{ end }} ",
          "type": "status"
        },
        {
          "background": "#575656",
          "foreground": "#7aabfc",
          "properties": {
            "style": "roundrock",
            "threshold": 0
          },
          "style": "diamond",
          "template": " \uf252 {{ .FormattedMs }} ",
          "trailing_diamond": "\ue0b4",
          "type": "executiontime"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "foreground": "#7aabfc",
          "style": "plain",
          "template": "\u256d\u2500",
          "type": "text"
        },
        {
          "foreground": "#bd7939",
          "properties": {
            "time_format": "<#7aabfc>\ue641 15:04:05</> <#79DFE1>|</> \uf073 2 Jan, Monday"
          },
          "style": "plain",
          "template": "{{ .CurrentDate | date .Format }} <#79DFE1>|</>",
          "type": "time"
        },
        {
          "foreground": "#3e7fb7",
          "leading_diamond": "<#00C7FC> \uf07b </><#3e7fb7> in </>",
          "properties": {
            "folder_icon": " \uf07c ",
            "folder_separator_icon": " \uf061 ",
            "home_icon": "\ueb06 ",
            "style": "agnoster_short",
            "max_depth": 3
          },
          "style": "diamond",
          "template": " {{ .Path }} ",
          "type": "path"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "foreground": "#7aabfc",
          "style": "plain",
          "template": "\u2570\u2500",
          "type": "text"
        },
        {
          "foreground": "#7aabfc",
          "properties": {
            "always_enabled": true
          },
          "style": "plain",
          "template": "\u276f ",
          "type": "status"
        }
      ],
      "type": "prompt"
    }
  ],
  "osc99": true,
  "transient_prompt": {
    "background": "transparent",
    "foreground": "#FEF5ED",
    "template": "\ue285 "
  },
  "secondary_prompt": {
    "background": "transparent",
    "foreground": "#7aabfc",
    "template": "\u2570\u2500\u276f "
  },
  "version": 2
}
相关推荐
飞飞-躺着更舒服6 分钟前
【QT】实现电子飞行显示器(改进版)
开发语言·qt
DWei_GaGa19 分钟前
Git:查看分支、创建分支、合并分支
git
武昌库里写JAVA22 分钟前
Java成长之路(一)--SpringBoot基础学习--SpringBoot代码测试
java·开发语言·spring boot·学习·课程设计
ZSYP-S1 小时前
Day 15:Spring 框架基础
java·开发语言·数据结构·后端·spring
yuanbenshidiaos1 小时前
c++------------------函数
开发语言·c++
程序员_三木1 小时前
Three.js入门-Raycaster鼠标拾取详解与应用
开发语言·javascript·计算机外设·webgl·three.js
是小崔啊1 小时前
开源轮子 - EasyExcel01(核心api)
java·开发语言·开源·excel·阿里巴巴
tianmu_sama1 小时前
[Effective C++]条款38-39 复合和private继承
开发语言·c++
黄公子学安全2 小时前
Java的基础概念(一)
java·开发语言·python
liwulin05062 小时前
【JAVA】Tesseract-OCR截图屏幕指定区域识别0.4.2
java·开发语言·ocr