Skip to content

Instantly share code, notes, and snippets.

@elalemanyo
Last active November 11, 2025 15:29
Show Gist options
  • Select an option

  • Save elalemanyo/cb3395af64ac23df2e0c3ded8bd63b2f to your computer and use it in GitHub Desktop.

Select an option

Save elalemanyo/cb3395af64ac23df2e0c3ded8bd63b2f to your computer and use it in GitHub Desktop.
Debug zsh startup time

Debug zsh startup time

  1. Inject profiling code

    At the beginning of your .zshrc add following: zmodload zsh/zprof

    and at the end add: zprof

    This will load zprof mod and display what your shell was doing durung your initialization.

  2. Measure startup time

    time zsh -i -c exit

@sharunkumar
Copy link

Thanks for guide! Based on this, I would also like to add my approach where I don't have to edit the rc file manually each time to check:

if [ -n "${ZSH_DEBUGRC+1}" ]; then
    zmodload zsh/zprof
fi

# rest of .zshrc script

if [ -n "${ZSH_DEBUGRC+1}" ]; then
    zprof
fi

then I just run:

time ZSH_DEBUGRC=1 zsh -i -c exit

@elalemanyo
Copy link
Author

@sharunkumar Thanks! Great idea. Check this to see how I implemented.

@adlternative
Copy link

helpful!

@yves-vogl
Copy link

And if you forget the command, you may add:

alias zsh_zprof=time ZSH_DEBUGRC=1 zsh -i -c exit

…so you can simply run zsh_zprofwhenever needed.

@elalemanyo
Copy link
Author

@yves-vogl It looks like you've reviewed my .zshrc 🙂

shot2025-11-11 at 12 41 35@2x

@yves-vogl
Copy link

All the credits belong to you ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment