oh-my-zsh's prompt is slow: how to fix this
I don't know what oh-my-zsh puts in the prompt by default. Maybe it tries to identify the version control status, that's a very popular prompt component which might be time-consuming.
To see what's going on, turn on command traces with set -x
.
→ ~ → ~ set -x trace of the commands that are executed to calculate the prompt → ~ trace of the commands that are executed to calculate the prompt → ~ set +x +zsh:3> set +x → ~ → ~
If the trace is so long that it scrolls off the screen, redirect it to a file with
exec 2>zsh.err
This directs all error messages to the file, not just the trace. To get traces and errors back on the terminal, run
exec 2>/dev/tty
You can customize the trace format through PS4
. This is a format string which can contain prompt escapes. For example, to add precise timing information:
PS4='%D{%s.%9.}+%N:%i> '