oh-my-posh 自定义主题配置
...2024年11月5日小于 1 分钟
oh-my-posh 自定义主题配置
简介
macOS 上可以使用 oh-my-zsh 来美化你的命令行提示。
windows 上可以使用 oh-my-posh 来美化你的 PowerShell 提示。
注
windows 下推荐使用 Windows Terminal 配合 PowerShell 来使用。
Oh My Posh 是一个开源的跨平台命令行提示工具,它可以让你的 PowerShell 显示漂亮的提示信息。
各自官网都有详细的安装和使用说明,本文不再赘述。
自定义主题配置
oh-my-posh 提供了丰富的主题配置,你可以在 主题 中找到你喜欢的主题。
当然,你也可以自定义主题。
下面就是本人定制后的效果,备份一下,方便以后使用。
效果
配置文件
点击这里下载配置文件:zhaobc.omp.json
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"version": 2,
"final_space": true,
"console_title_template": "{{ .Shell }} in {{ .Folder }}",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "session",
"style": "diamond",
"leading_diamond": "\ue0b6",
"template": " {{ .UserName }} ",
"background": "#c386f1",
"foreground": "#ffffff"
},
{
"type": "path",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"template": " \uea83 {{ .Path }} ",
"properties": {
"folder_separator_icon": " \ue0b1 ",
"home_icon": "\ueb06",
"style": "folder"
},
"background": "#ff479c",
"foreground": "#ffffff"
},
{
"type": "git",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"background_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}#FF9248{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}#ff4500{{ end }}",
"{{ if gt .Ahead 0 }}#B388FF{{ end }}",
"{{ if gt .Behind 0 }}#B388FF{{ end }}"
],
"leading_diamond": "\ue0b6",
"trailing_diamond": "\ue0b4",
"template": " {{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \ueb4b {{ .StashCount }}{{ end }} ",
"properties": {
"branch_max_length": 25,
"fetch_stash_count": true,
"fetch_status": true,
"fetch_upstream_icon": true
},
"background": "#fffb38",
"foreground": "#193549"
},
{
"type": "node",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"template": " \ue718 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }} ",
"properties": {
"fetch_version": true
},
"background": "#6CA35E",
"foreground": "#ffffff"
},
{
"type": "go",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"template": " \ue626 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} ",
"properties": {
"fetch_version": true
},
"background": "#8ED1F7",
"foreground": "#111111"
},
{
"type": "julia",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"template": " \ue624 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} ",
"properties": {
"fetch_version": true
},
"background": "#4063D8",
"foreground": "#111111"
},
{
"type": "python",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"template": " \ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} ",
"properties": {
"display_mode": "files",
"fetch_virtual_env": false
},
"background": "#FFDE57",
"foreground": "#111111"
},
{
"type": "ruby",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"template": " \ue791 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} ",
"properties": {
"display_mode": "files",
"fetch_version": true
},
"background": "#AE1401",
"foreground": "#ffffff"
},
{
"type": "azfunc",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"template": " \uf0e7{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} ",
"properties": {
"display_mode": "files",
"fetch_version": false
},
"background": "#FEAC19",
"foreground": "#ffffff"
},
{
"type": "aws",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"background_templates": [
"{{if contains \"default\" .Profile}}#FFA400{{end}}",
"{{if contains \"jan\" .Profile}}#f1184c{{end}}"
],
"template": " \ue7ad {{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }} ",
"properties": {
"display_default": false
},
"foreground": "#ffffff"
},
{
"type": "root",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"template": " \uf0ad ",
"background": "#ffff66",
"foreground": "#111111"
},
{
"type": "status",
"style": "diamond",
"background_templates": ["{{ if gt .Code 0 }}#e91e63{{ end }}"],
"trailing_diamond": "\ue0b4",
"template": " \ue23a ",
"properties": {
"always_enabled": true
},
"background": "#00897b",
"foreground": "#ffffff"
}
]
},
{
"alignment": "right",
"type": "prompt",
"segments": [
{
"type": "shell",
"style": "diamond",
"template": "<#0077c2,transparent>\ue0b6</> \uf489 {{ .Name }} ",
"background": "#0077c2",
"foreground": "#ffffff"
},
{
"type": "executiontime",
"style": "powerline",
"powerline_symbol": "\ue0b2",
"invert_powerline": true,
"template": " {{ .FormattedMs }}\u2800",
"properties": {
"always_enabled": true
},
"background": "#83769c",
"foreground": "#ffffff"
},
{
"type": "ytm",
"style": "powerline",
"powerline_symbol": "\ue0b2",
"invert_powerline": true,
"template": " \uf167 {{ .Icon }}{{ if ne .Status \"stopped\" }}{{ .Artist }} - {{ .Track }}{{ end }} ",
"properties": {
"paused_icon": "\uf04c ",
"playing_icon": "\uf04b "
},
"background": "#1BD760",
"foreground": "#111111"
},
{
"type": "battery",
"style": "powerline",
"powerline_symbol": "\ue0b2",
"invert_powerline": true,
"background_templates": [
"{{if eq \"Charging\" .State.String}}#40c4ff{{end}}",
"{{if eq \"Discharging\" .State.String}}#ff5722{{end}}",
"{{if eq \"Full\" .State.String}}#4caf50{{end}}"
],
"template": " {{ if not .Error }}{{ .Icon }}{{ .Percentage }}{{ end }}{{ .Error }}\uf295 ",
"properties": {
"charged_icon": "\ue22f ",
"charging_icon": "\ue234 ",
"discharging_icon": "\ue231 "
},
"background": "#f36943",
"foreground": "#ffffff"
},
{
"type": "time",
"properties": {
"time_format": "15:04"
},
"style": "diamond",
"invert_powerline": true,
"trailing_diamond": "\ue0b4",
"template": " {{ .CurrentDate | date .Format }} ",
"background": "#c386f1",
"foreground": "#111111"
}
]
},
{
"alignment": "left",
"newline": true,
"segments": [
{
"foreground": "#ffffff",
"foreground_templates": ["{{ if gt .Code 0 }}#ff0000{{ end }}"],
"properties": {
"always_enabled": true
},
"style": "plain",
"template": "\u276f ",
"type": "status"
}
],
"type": "prompt"
}
]
}
你认为这篇文章怎么样?
- 0
- 0
- 0
- 0
- 0
- 0
Powered by Waline v3.3.2