ohmyzsh/lib
Raj Aryan e65e21dc3a
perf(git): speed up prompt by skipping untracked files check - Modify _omz_git_prompt_status to respect DISABLE_UNTRACKED_FILES_DIRTY - Avoid scanning untracked files in large repos - Backward compatible, default behavior unchanged
PR Description
Problem

The Git prompt in Oh My Zsh is extremely slow (2–5 seconds) in large repositories, especially on machines with file/network auditing (like office Macs).
The slowdown is caused by:

git status --porcelain -b scanning untracked files

Repeated git rev-list and show-ref calls

Solution

Introduced a lightweight fix using the existing DISABLE_UNTRACKED_FILES_DIRTY environment variable.

When set to true, the prompt skips scanning untracked files:

DISABLE_UNTRACKED_FILES_DIRTY=true


Updated _omz_git_prompt_status to respect this variable.

All other prompt behavior remains unchanged.

How to Use

Add to your .zshrc before sourcing Oh My Zsh:

export DISABLE_UNTRACKED_FILES_DIRTY=true


Reload the shell:

exec zsh

Before vs After
Action	Before	After
Enter large Git repo	~2–5s delay	<0.5s
Tab completion for branches	4–5s delay	<0.2s
Prompt shows branch	Yes	Yes
Additional Notes

Optional: users can still disable the status portion entirely with:

export DISABLE_GIT_PROMPT_STATUS=true


Fully backward compatible.

Related Issue

Fixes #13082
2025-10-01 20:55:03 +05:30
..
tests fix(cli): fix edge cases in omz plugin disable command (#12401) 2024-05-08 22:20:42 +02:00
async_prompt.zsh fix(termsupport): ensure ohmyzsh can run with set -eu 2025-03-20 20:02:34 +01:00
bzr.zsh refactor(bzr): simplify and improve code (#12716) 2024-10-02 15:30:32 +02:00
cli.zsh feat(cli): only allow omz pr test on PRs with testers needed label (#13238) 2025-09-19 15:58:21 +02:00
clipboard.zsh fix(clipboard): remove clippaste additional newline on wayland (#12140) 2023-12-31 11:17:37 +01:00
compfix.zsh style: remove trailing whitespace (#12303) 2024-03-26 09:55:16 +01:00
completion.zsh chore: fix typos (#13219) 2025-07-21 18:39:25 +02:00
correction.zsh fix(correction)!: remove aliases for non standard commands 2023-02-15 09:23:04 +01:00
diagnostics.zsh style: remove trailing whitespace (#12303) 2024-03-26 09:55:16 +01:00
directories.zsh feat(init)!: allow turning off aliases for libs and plugins (#11550) 2023-04-03 23:14:36 +02:00
functions.zsh fix(functions): escape especial chars in WSL (#13158) 2025-06-08 10:25:23 +02:00
git.zsh perf(git): speed up prompt by skipping untracked files check - Modify _omz_git_prompt_status to respect DISABLE_UNTRACKED_FILES_DIRTY - Avoid scanning untracked files in large repos - Backward compatible, default behavior unchanged 2025-10-01 20:55:03 +05:30
grep.zsh feat(grep): exclude Python virtualenv from grep (#12685) 2024-10-08 20:29:30 +02:00
history.zsh fix(history): handle HIST_STAMPS with whitespace in timestamp format (#13099) 2025-05-22 11:23:50 +02:00
key-bindings.zsh docs(key-bindings): clarify comment 2025-08-16 21:26:22 +02:00
misc.zsh chore: fix some typos (#12818) 2024-11-21 09:01:48 +01:00
nvm.zsh fix(lib): quote % in nvm_prompt_info 2022-01-03 13:50:50 +01:00
prompt_info_functions.zsh feat(conda-env): add plugin for conda prompt display (#10619) 2024-07-15 18:56:44 +02:00
spectrum.zsh feat(spectrum): add FX[dim] format (#12172) 2024-01-21 05:25:50 +01:00
termsupport.zsh fix(termsupport): ensure non-error return code (#13217) 2025-07-21 11:11:35 +02:00
theme-and-appearance.zsh fix(theme-and-appearance): make bsd ls to be default 2023-05-09 12:05:15 +02:00
vcs_info.zsh fix(lib): fix return code after expected non-zero exit code (#11524) 2023-02-24 17:27:23 +01:00