当前位置: 首页 > article >正文

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

在这里插入图片描述
C:\Users\root\Documents\WindowsPowerShell中写如下内容

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中写如下内容

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中写如下内容

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

要加 -i -l


在这里插入图片描述
要加cmd.exe /k


在这里插入图片描述
要取消勾选仅显示等宽字体


亮色配色
在这里插入图片描述
kushal.omp.json,修改自kushal.omp.json

{
  "$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
}


http://www.kler.cn/a/331350.html

相关文章:

  • 我的个人博客正式上线了!
  • CCF-GESP 等级考试 2023年9月认证C++一级真题解析
  • spring学习(spring-DI(setter注入、构造器注入、自动装配方式))
  • ChatGPT与领域特定语言的集成
  • 【C#】Ctrl+ 组合键的使用
  • 游戏渠道假量解决方案
  • CSS实现文本超出隐藏并显示省略号
  • 【SpringBoot】基础+JSR303数据校验
  • 原生 JS 操作 DOM 元素
  • 图的最短路径算法Floyed
  • 浅谈PyTorch中的DP和DDP
  • 2024年中国科技核心期刊目录(社会科学卷)
  • tailwindcss快速入门(上篇)
  • Web安全 - 构建全面的业务安全保护防御体系
  • 深度学习数据增强的常用方法
  • 滚雪球学Oracle[4.6讲]:存储过程与函数
  • 短视频矩阵系统源码开发/矩阵系统OEM搭建--源代码开发经验分享
  • NVIDIA G-Assist 项目:您的游戏和应用程序AI助手
  • 树莓派 AI 摄像头(Raspberry Pi AI Camera)教程
  • 计网问答大题(期末复习)
  • [C++][第三方库][etcd]详细讲解
  • vue3项目el-table表格行内编辑加输入框校验
  • RabbitMQ 消息队列:生产者与消费者实现详解
  • Linux文件重定向文件缓冲区
  • 【漏洞复现】大华智慧园区综合管理平台 video 任意文件上传漏洞
  • 【rCore OS 开源操作系统】Rust mod模块和static生命周期 知识点及练习题