Browse Source

oh-my-posh

raylu 8 months ago
parent
commit
ba580e9326
2 changed files with 121 additions and 1 deletions
  1. 118 0
      config/oh-my-posh.toml
  2. 3 1
      zshrc

+ 118 - 0
config/oh-my-posh.toml

@@ -0,0 +1,118 @@
+'$schema' = 'https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json'
+
+version = 3
+console_title_template = '{{ .Shell }} in {{ .Folder }}'
+final_space = true
+
+[upgrade]
+  notice = true
+
+[[blocks]]
+  type = 'prompt'
+  alignment = 'left'
+  newline = true
+
+  [[blocks.segments]]
+    template = ' {{ if .WSL }} {{ end }}'
+    foreground = '#efdcf9'
+    background = '#0e050f'
+    type = 'os'
+    style = 'diamond'
+
+  [[blocks.segments]]
+    template = '{{ if .SSHSession }} {{ end }}{{ if .Root }}root {{ end }}{{ .HostName }}'
+    foreground = '#efdcf9'
+    foreground_templates = ['{{ if .Root }}#ff3c3c{{ end }}']
+    background = '#0e050f'
+    type = 'session'
+    style = 'diamond'
+
+  [[blocks.segments]]
+    type = 'path'
+    template = ' {{ .Path }} '
+    foreground = '#efdcf9'
+    background = '#170b3b'
+    style = 'powerline'
+    powerline_symbol = ''
+    [blocks.segments.properties]
+      style = 'mixed'
+	  mixed_threshold = 16
+      folder_icon = ''
+      display_root = true
+
+  [[blocks.segments]]
+    type = 'git'
+    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 }} '
+    foreground = '#efdcf9'
+    background = '#341948'
+    style = 'powerline'
+    powerline_symbol = ''
+    [blocks.segments.properties]
+      branch_template = '{{ trunc 25 .Branch }}'
+      fetch_stash_count = true
+      fetch_status = true
+      fetch_upstream_icon = true
+
+  [[blocks.segments]]
+    type = 'time'
+    template = ' {{ .CurrentDate | date .Format }} '
+    foreground = '#efdcf9'
+    background = '#4c1f5e'
+    style = 'powerline'
+    powerline_symbol = ''
+    [blocks.segments.properties]
+      time_format = '15:04'
+
+  [[blocks.segments]]
+    type = 'executiontime'
+    template = '{{ .FormattedMs }} '
+    foreground = '#efdcf9'
+    background = '#4c1f5e'
+    style = 'powerline'
+    powerline_symbol = ''
+
+  [[blocks.segments]]
+    type = 'text'
+    template = '{{ if gt .SHLVL 1 }} SHLVL:{{ .SHLVL }} {{ end }}'
+    foreground = '#efdcf9'
+    background = '#5a276a'
+    style = 'diamond'
+    trailing_diamond = ''
+
+  [[blocks.segments]]
+    type = 'text'
+    template = '{{ if gt .Jobs 0 }} {{ .Jobs }} {{ end }}'
+    foreground = '#efdcf9'
+    background = '#69307a'
+    style = 'diamond'
+    trailing_diamond = ''
+    [blocks.segments.properties]
+      always_enabled = true
+
+  [[blocks.segments]]
+    type = 'status'
+    template = '{{ if gt .Code 0 }} {{ .String }} {{ end }}'
+    foreground = '#efdcf9'
+    background = '#754083'
+    style = 'diamond'
+    trailing_diamond = ''
+
+[[blocks]]
+  type = 'prompt'
+  alignment = 'left'
+  newline = true
+  [[blocks.segments]]
+    type = 'text'
+    style = 'plain'
+    template = '{{ if .Root }}#{{ else }}${{ end }}'
+    background_templates = ['{{ if .Root }}#771111{{ end }}']
+
+[[tooltips]]
+  tips = ['pydoc3', 'python', 'python3', 'uv', 'pip', 'pip3']
+  type = 'python'
+  template = ' {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }}'
+  foreground = '#efdcf9'
+  background = '#341948'
+  style = 'diamond'
+  leading_diamond = ''
+  trailing_diamond = ''

+ 3 - 1
zshrc

@@ -126,7 +126,9 @@ if [ -d $HOME/bin ]; then
 	PATH=$HOME/bin:$PATH
 fi
 
-if builtin which starship > /dev/null; then
+if builtin which oh-my-posh > /dev/null; then
+	eval "$(oh-my-posh init zsh -c ~/.config/oh-my-posh.toml)"
+elif builtin which starship > /dev/null; then
 	eval "$(starship init zsh)"
 else
 	autoload colors