Fixing Oh My Zsh Prompt Lag in Large Git Repositories
Oh My Zsh prompts can lag in large repos because themes scan for untracked files on every command. Learn how to use DISABLE_UNTRACKED_FILES_DIRTY to restore prompt speed without losing git integration.
13 Mar 2026, 04:29 UTC

If your terminal pauses for a fraction of a second every time you press Enter while working in a monorepo, the culprit is likely your shell prompt. Many Oh My Zsh themes execute a git status check on every precmd—the Zsh hook that runs immediately before the prompt is drawn. In repositories with thousands of files, the cost of scanning for untracked files can make the shell feel sluggish.
The Cost of Untracked File Scanning
To determine if a repository is "dirty," git must check if any files have changed. While checking tracked files is relatively fast, identifying untracked files requires git to stat many paths to determine if they are ignored or new. When this happens on every single command execution, the cumulative latency becomes noticeable.
Using DISABLE_UNTRACKED_FILES_DIRTY
Oh My Zsh provides a built-in configuration variable to skip the most expensive part of the status check. Setting DISABLE_UNTRACKED_FILES_DIRTY="true" tells the git plugin and compatible themes to ignore untracked files when calculating the prompt's dirty state.
This variable must be exported in your ~/.zshrc before the line that sources oh-my-zsh.sh. This ensures the git plugin reads the setting during its initialization phase.
# ~/.zshrc
# Set this BEFORE sourcing oh-my-zsh.sh
export DISABLE_UNTRACKED_FILES_DIRTY="true"
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="robbyrussell"
plugins=(git)
source $ZSH/oh-my-zsh.sh
Expected Result: Your prompt will still show the current branch and indicate if tracked files are modified, but it will no longer lag while scanning for new, untracked files.
Risk: You lose the visual indicator (like an asterisk or color change) that tells you a new file exists in your directory until you manually run git status.
Reducing Overhead via Plugin Scoping
If the prompt is still slow, the issue may be the sheer volume of tracked changes or the theme's implementation. A more aggressive engineering decision is to remove the git plugin from the global plugins=() array. This removes the git-specific aliases and prompt helpers from every session.
To maintain functionality without the global overhead, you can use the $ZSH_CUSTOM directory (which defaults to $ZSH/custom). Oh My Zsh sources this directory after its core scripts, allowing you to load specific helpers or custom scripts only when needed, rather than loading the full git plugin suite into every shell instance.
Verification and Diagnostics
To verify the performance gain, you can time the shell's initialization and prompt rendering inside the target repository. Run the following command from your terminal:
# Run this inside your large git repository
time zsh -ic exit
Run this once with DISABLE_UNTRACKED_FILES_DIRTY="true" and once without. The difference in execution time isolates the cost of the untracked-file scan. Note that filesystem caching may affect results; repeat the test several times to get a consistent average.
You can also verify which helpers your current theme is calling by searching the theme file:
grep -n "git_prompt_info\|git_status" "$ZSH/themes/your-theme-name.zsh-theme"
Trade-offs and Limitations
- Tracked Files: This setting only skips untracked files. If you have thousands of modified tracked files, the prompt may still experience latency.
- Theme Dependency: Some themes invoke git helpers unconditionally, while others check if you are inside a git directory first. If your theme is inefficient, you may still see lag in non-git directories.
- Visibility: The primary trade-off is the loss of the "untracked files" visual cue in the prompt.
Summary of Action
For most users, adding export DISABLE_UNTRACKED_FILES_DIRTY="true" to the top of ~/.zshrc is the most effective balance between visibility and performance. If the lag persists, audit your theme's use of git_prompt_info and consider removing the git plugin from your global configuration.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.