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
}
相关推荐
XiaoLeisj42 分钟前
【JavaEE初阶 — 多线程】单例模式 & 指令重排序问题
java·开发语言·java-ee
励志成为嵌入式工程师2 小时前
c语言简单编程练习9
c语言·开发语言·算法·vim
捕鲸叉2 小时前
创建线程时传递参数给线程
开发语言·c++·算法
A charmer2 小时前
【C++】vector 类深度解析:探索动态数组的奥秘
开发语言·c++·算法
Peter_chq2 小时前
【操作系统】基于环形队列的生产消费模型
linux·c语言·开发语言·c++·后端
记录成长java4 小时前
ServletContext,Cookie,HttpSession的使用
java·开发语言·servlet
前端青山4 小时前
Node.js-增强 API 安全性和性能优化
开发语言·前端·javascript·性能优化·前端框架·node.js
睡觉谁叫~~~4 小时前
一文解秘Rust如何与Java互操作
java·开发语言·后端·rust
音徽编程4 小时前
Rust异步运行时框架tokio保姆级教程
开发语言·网络·rust
观音山保我别报错4 小时前
C语言扫雷小游戏
c语言·开发语言·算法