# oh-my-posh-theme **Repository Path**: JOE-525/oh-my-posh-theme ## Basic Information - **Project Name**: oh-my-posh-theme - **Description**: oh-my-posh主题 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2022-06-25 - **Last Updated**: 2023-12-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # oh-my-posh theme 本主题样式: ![主题](/theme.png) > 官方教程为 https://ohmyposh.dev/docs/installation/prompt * 可将本仓库clone后将`my.omp.json`放到`oh-my-posh`的`theme`文件夹下, `oh-my-posh`下载见下面 * 或将下面[提供的样式](#样式)复制再自己在`oh-my-posh`的`theme`文件夹下新建一个`.omp.json`文件, 将其粘贴进去 # 步骤 1. 用choco进行下载 ``` shell choco install oh-my-posh ``` 2. 查询自己终端类型 ```shell oh-my-posh get shell ``` 3. 字体为 `MeslolGM Nerd Font Mono` (这个字体可以适配其他主题, 本主题大概率是不需要的) ## git bash 修改样式 1. 在`~`创建`.bashrc`文件 ```shell vim .bashrc ``` 2. 将下面的内容复制到改文件中 ``` shell eval "$(oh-my-posh --init --shell bash --config /c/Program\ Files\ \(x86\)/oh-my-posh/themes/ys.omp.json)" ``` 注: * `/c/Program\ Files\ \(x86\)/oh-my-posh`为我自己`oh-my-posh`所在路径, 如果是用`choco`下载的大概率是在相同位置 * `Program\ Files\ \(x86\)` 中的`\`为转义字符 * `ys.omp.json`为仓库的另一个文件 3. 执行下面的命令, 样式就会生效 ``` shell exec bash ``` ## windows powershell 样式修改 1. 使用下面的命令打开创建`.ps1`脚本, 如果没有, 填写完第2步的内容之后保存就行 ```shell notepad $PROFILE ``` 2. 将下面的内容复制进改文件中 ```shell & ([ScriptBlock]::Create((oh-my-posh init pwsh --config "C:\Program Files (x86)\oh-my-posh\themes\ys.omp.json" --print) -join "`n")) $env:VIRTUAL_ENV_DISABLE_PROMPT = 1 ``` 注: * 第一行内容为执行的命令(包含前面的`&`) * 第二行内容为关闭python虚拟环境在命令行左侧的显示 3. 以管理员角色打开`windows powershell`, 执行以下命令: 1. 进入该文件所在文件夹 ```shell cd C:\Users\19041\Documents\WindowsPowerShell ``` 2. 加载改命令 ```shell set-executionpolicy remotesigned ``` 3. 执行脚本 ```shell .\Microsoft.PowerShell_profile.ps1 ``` # 样式 > 即 `my.omp.json`文件的内容 ```json { "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", "blocks": [ { "alignment": "left", "segments": [ { "foreground": "red", "style": "plain", "template": "\u279c", "type": "text" }, { "foreground": "lightYellow", "style": "plain", "template": " {{ .UserName }} ", "type": "session" }, { "foreground": "cyan", "properties": { "style": "full" }, "style": "plain", "template": "<#ffffff>in {{ .Path }} ", "type": "path" }, { "foreground": "#ff94df", "properties": { "branch_icon": " <#ff94df>\ue0a0 ", "fetch_stash_count": true }, "style": "plain", "template": "<#ffffff>on {{ .HEAD }}{{ if gt .StashCount 0 }} \uf692 {{ .StashCount }}{{ end }} ", "type": "git" }, { "foreground": "#906cff", "style": "powerline", "template": "[\ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }}] ", "type": "python" }, { "foreground": "#7FD5EA", "style": "powerline", "template": "[\ufcd1 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}] ", "type": "go" }, { "foreground": "#76b367", "style": "powerline", "template": "[\ue718 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }}] ", "type": "node" }, { "foreground": "#f44336", "style": "powerline", "template": "[\ue791{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}] ", "type": "ruby" }, { "foreground": "#ea2d2e", "style": "powerline", "template": "[\ue738 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}] ", "type": "java" }, { "foreground": "#4063D8", "style": "powerline", "template": " \ue624 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} ", "type": "julia" } ], "type": "prompt" }, { "alignment": "left", "newline": true, "segments": [ { "foreground": "red", "style": "plain", "template": "✘", "type": "text" } ], "type": "prompt" } ], "final_space": true, "version": 2 } ```