Skip to content

macOS zsh oh-my-posh startup is visually slow #7430

@davidsanchez222

Description

@davidsanchez222

Code of Conduct

  • I agree to follow this project's Code of Conduct

What would you like to see changed?

poshdelay.mp4

Attached is a video that shows the difference in when the prompt shows up for p10k and oh-my-posh. The first run is the p10k version. Notice how the pixels for ~/code don't move for the p10k version. I used the most minimal version I could of my oh-my-posh .zshrc. I used my full p10k .zshrc with more things loaded and it still looks faster. I think the difference here is that p10k uses instant prompt.

However, I see a PR that was merged here that related to instant prompt. #6427

I tried turning on streaming and async, but those didn't help. I commented out

  [[blocks.segments]]
    type = 'git'
    style = 'plain'
    foreground = 'p:grey'
    background = 'transparent'
    template = ' {{ .HEAD }}{{ if or (.Working.Changed) (.Staging.Changed) }}*{{ end }} <cyan>{{ if gt .Behind 0 }}⇣{{ end }}{{ if gt .Ahead 0 }}⇡{{ end }}</>'

    [blocks.segments.properties]
      branch_icon = ''
      commit_icon = '@'
      fetch_status = true

but that didn't help either. Nothing I did could get it to look as fast as p10k.

zen.toml

"$schema" = "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json"
version = 4
final_space = true
async = true
streaming = 100
console_title_template = '{{ .Shell }} in {{ .Folder }}'

[[blocks]]
  type = 'prompt'
  alignment = 'left'
  newline = true

  [[blocks.segments]]
    type = 'path'
    style = 'plain'
    background = 'transparent'
    foreground = 'blue'
    template = '{{ .Path }}'

    [blocks.segments.properties]
      style = 'full'

  [[blocks.segments]]
    type = 'python'
    style = 'plain'
    foreground = 'yellow'
    background = 'transparent'
    template = ' ({{ .Venv }})'

    [blocks.segments.properties]
      display_mode = 'environment'
      display_default = false
      fetch_version = false

  [[blocks.segments]]
    type = 'git'
    style = 'plain'
    foreground = 'p:grey'
    background = 'transparent'
    template = ' {{ .HEAD }}{{ if or (.Working.Changed) (.Staging.Changed) }}*{{ end }} <cyan>{{ if gt .Behind 0 }}⇣{{ end }}{{ if gt .Ahead 0 }}⇡{{ end }}</>'

    [blocks.segments.properties]
      branch_icon = ''
      commit_icon = '@'
      fetch_status = true


[[blocks]]
  type = 'rprompt'
  overflow = 'hidden'

  [[blocks.segments]]
    type = 'executiontime'
    style = 'plain'
    foreground = 'yellow'
    background = 'transparent'
    template = '{{ .FormattedMs }}'

    [blocks.segments.properties]
      threshold = 5000

[[blocks]]
  type = 'prompt'
  alignment = 'left'
  newline = true

  [[blocks.segments]]
    type = 'text'
    style = 'plain'
    foreground_templates = [
      "{{if gt .Code 0}}red{{end}}",
      "{{if eq .Code 0}}magenta{{end}}",
    ]
    background = 'transparent'
    template = '❯'

[transient_prompt]
  foreground_templates = [
    "{{if gt .Code 0}}red{{end}}",
    "{{if eq .Code 0}}magenta{{end}}",
  ]
  background = 'transparent'
  template = '❯ '

[secondary_prompt]
  foreground = 'magenta'
  background = 'transparent'
  template = '❯❯ '

.zshrc (posh version)

if [ "$TERM_PROGRAM" != "Apple_Terminal" ]; then
    eval "$(oh-my-posh init zsh --config $HOME/.config/ohmyposh/zen.toml)"
fi

if [[ -f "/opt/homebrew/bin/brew" ]] then
  # If you're using macOS, you'll want this enabled
  eval "$(/opt/homebrew/bin/brew shellenv)"
fi

# Set the directory we want to store zinit and plugins
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"

# Download Zinit, if it's not there yet
if [ ! -d "$ZINIT_HOME" ]; then
   mkdir -p "$(dirname $ZINIT_HOME)"
   git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
fi

# Source/Load zinit
source "${ZINIT_HOME}/zinit.zsh"


# Add in zsh plugins
zinit light zsh-users/zsh-syntax-highlighting
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-autosuggestions
zinit light Aloxaf/fzf-tab

# Add in snippets
zinit snippet OMZL::git.zsh
zinit snippet OMZP::git
zinit snippet OMZP::sudo
zinit snippet OMZP::archlinux
zinit snippet OMZP::aws
zinit snippet OMZP::kubectl
zinit snippet OMZP::kubectx
zinit snippet OMZP::command-not-found

# Load completions
autoload -Uz compinit && compinit

zinit cdreplay -q

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions