简介
Oh My Posh 是一个适用于任何 shell 的命令提示符主题引擎。相比于Oh My ZSH我觉得最大的优点就是启动速度快,而且适合于所有的shell,有各种各样的插件
安装
mac 直接使用下面命令安装
brew install jandedobbeleer/oh-my-posh/oh-my-posh
配置
支持json,yaml,toml三种配置格式,如果懒得配置的话,可以直接使用分享出来的主题,然后自己修修补补
https://ohmyposh.dev/docs/themes
案例一般都是使用json,但是我喜欢使用yaml,下面是我的配置
yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
final_space: true
auto_upgrade: false
disable_notice: true
version: 2
blocks:
- type: prompt
alignment: left
segments:
- type: path
style: diamond
foreground: "#F1FA8C"
properties:
style: folder
- type: executiontime
style: diamond
foreground: "#F1FA8C"
template: "{{ .FormattedMs }} "
properties:
threshold: 500
style: austin
always_enabled: true
- type: git
style: diamond
foreground: "#B15BFF"
template:
"{{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus
}}{{ end }}{{ if .Working.Changed }} {{ .Working.String }}{{ end }}{{ if and
(.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }}
{{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} {{ .StashCount }}{{
end }}"
properties:
fetch_status: true
fetch_upstream_icon: true
untracked_modes:
/Users/user/Projects/oh-my-posh/: no
- type: prompt
alignment: right
segments:
- type: time
style: plain
foreground: "#0066CC"
properties:
time_format: 15:04:05
- type: ipify
style: diamond
foreground: "#00FFFF"
template: "{{ .IP }}"
properties:
cache_timeout: 5
http_timeout: 1000
- type: prompt
alignment: left
newline: true
segments:
- type: text
style: plain
foreground: "#F75000"
template: ">>>"
配置起来其实很简单,有一部分通用配置
https://ohmyposh.dev/docs/configuration/general#general-settings
可以按需配置,其他的都是Block和Segment,插件可以自己选配,把配置存储成yaml文件或者json文件,然后如果你和我一样使用zsh,只要把下面加入~/.zshrc
就好了
eval "$(oh-my-posh init zsh --config /Users/bboysoul/.bboysoul.omp.yaml)"
欢迎关注我的博客www.bboy.app
Have Fun