Skip to content

Instantly share code, notes, and snippets.

@erhhung
Last active August 20, 2024 03:48
Show Gist options
  • Save erhhung/e745a1d023d75fcaecb9a827c5d1db5f to your computer and use it in GitHub Desktop.
Save erhhung/e745a1d023d75fcaecb9a827c5d1db5f to your computer and use it in GitHub Desktop.
Custom Oh-My-Posh theme

oh-my-posh-theme

"~/.config/oh-my-posh/erhhung.omp.yaml"

$schema: https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
version: 2
iterm_features:
  - current_dir
  - remote_host
  #- prompt_mark
blocks:
  - type: prompt
    alignment: left
    newline: true
    segments:
      # https://ohmypo.sh/docs/segments/system/text
      - type: text
        style: plain
        foreground: '#888888'
        template: ╭─
      # https://ohmypo.sh/docs/segments/system/path
      - type: path
        style: diamond
        leading_diamond: 
        trailing_diamond: 
        foreground: '#e4e4e4'
        background: '#404040'
        template: '<b>{{ replaceP "^/" (replaceP "^~<#ddee80>∕</>" .Path " ") "<#ddee80>∕</>" }}</>'
        properties:
          style: full
          folder_separator_icon: '<#ddee80>∕</>'
      # https://ohmypo.sh/docs/segments/cloud/aws
      - type: aws
        style: diamond
        trailing_diamond: 
        foreground: '#2f2f40'
        background: '#30c8a8'
        template: '  {{ .Profile }}{{ if .Region }} ⁞ {{ .Region }}{{ end }}'
        properties:
          display_default: false
      # https://ohmypo.sh/docs/segments/cli/kubectl
      - type: kubectl
        style: diamond
        trailing_diamond: 
        foreground: '#e4e4e4'
        background: '#1060c0'
        template: ' ⎈ {{ .Context }} ⁞ {{ or .Namespace "default" }}'
      # https://ohmypo.sh/docs/segments/languages/python
      - type: python
        style: diamond
        trailing_diamond: 
        foreground: '#96e072'
        background: '#2f2f2f'
        template: '  {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }}</>'
      # https://ohmypo.sh/docs/segments/scm/git
      - type: git
        style: diamond
        trailing_diamond: 
        foreground: '#011620'
        background: '#fffb40'
        background_templates:
          - '{{ if or (.Working.Changed) (.Staging.Changed) }}#ffeb95{{ end }}'
          - '{{ if and (gt .Ahead 0) (gt .Behind 0) }}#c5e478{{ end }}'
          - '{{ if gt .Ahead 0 }}#c792ea{{ end }}'
          - '{{ if gt .Behind 0 }}#c792ea{{ end }}'
        template: ' {{ .HEAD }} {{ if .Working.Changed }}{{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }}<#ef5350>  {{ .Staging.String }}</>{{ end }}'
        properties:
          branch_icon: ''
          fetch_status: true
          fetch_upstream_icon: true
  - type: prompt
    alignment: right
    segments:
      # https://ohmypo.sh/docs/segments/system/executiontime
      - type: executiontime
        style: diamond
        leading_diamond: 
        trailing_diamond: 
        foreground: '#ffffff'
        background: '#d770a0'
        template: ' {{ .FormattedMs }}'
        properties:
          style: austin
          always_enabled: true
      # https://ohmypo.sh/docs/segments/system/time
      - type: time
        style: diamond
        trailing_diamond: 
        foreground: '#ffffff'
        background: '#1888c0'
        template: ' {{ .CurrentDate | date .Format | trimSuffix "m" }}'
        properties:
          time_format: 3:04:05pm
  - type: prompt
    alignment: left
    newline: true
    segments:
      # https://ohmypo.sh/docs/segments/system/text
      - type: text
        style: plain
        # iterm_features[].prompt_mark adds the mark on
        # a new (third) line with the cursor just after
        # it at column 0, so enable it manually instead.
        template: '$(iterm2_prompt_mark)<#888888>╰─'
        # however, doing so turns the root bolt-in-oval
        # into ugly reverse video, so keep it disabled.
        template: '<#888888>╰─'
      # https://ohmypo.sh/docs/segments/system/root
      - type: root
        style: diamond
        leading_diamond: 
        trailing_diamond: 
        foreground: '#fffb38'
        background: '#ef5350'
        template: 
      # https://ohmypo.sh/docs/segments/system/status
      - type: status 
        style: diamond
        # not sure why, but .Code is always 0...
        template: '<b>{{ if not .Root }}<{{ if eq .Code 0 }}#fffb38{{ else }}#ef5350{{ end }}>❯{{ end }}</>'
        properties:
          always_enabled: true
# https://ohmypo.sh/docs/configuration/secondary-prompt
secondary_prompt:
  background: transparent
  foreground: '#ffffff'
  template: '  <b>{{ if .Root }}  {{ else }}❯{{ end }}</> '
final_space: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment