oh-my-zsh
Git performance
shell optimization
repository issues
terminal slowness

oh-my-zsh slow, but only for certain Git repo

Data Structures & Algorithms practice on Codemia

Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.

Practice algorithms

Introduction

When oh-my-zsh is slow only in specific repositories, prompt git status checks are usually the bottleneck. Large untracked files, deep submodules, and expensive git metadata queries can make each prompt render laggy. The fix is to profile prompt behavior and reduce per-prompt git workload.

Confirm the Slow Path

First, verify slowdown is prompt-related and repository-specific. Time a simple command and prompt redraw in the affected repo versus a small repo.

bash
time git status --porcelain=v1 -uno

time zsh -i -c 'echo prompt-test'

If git status is slow only in one repository, prompt git integration is likely the culprit.

Reduce Prompt Git Work

Many themes call multiple git commands per prompt. Disable expensive checks and simplify plugins.

zsh
1# ~/.zshrc
2plugins=(git)
3
4# Speed flags for common themes
5DISABLE_UNTRACKED_FILES_DIRTY="true"
6ENABLE_CORRECTION="false"
7
8# Optional: skip vcs info in very large repos
9export VCS_INFO_maxexports=2

After edits, reload shell and compare prompt responsiveness. Keep changes minimal and measurable.

Repository-Level Optimizations

Some repos are slow because of giant untracked directories, generated artifacts, or submodule scans. Reduce git work at repo level.

bash
1# Ignore build output that changes often
2echo "dist/" >> .git/info/exclude
3echo "node_modules/" >> .git/info/exclude
4
5# Improve status performance
6git config core.untrackedCache true
7git config core.fsmonitor true

Use local excludes for machine-specific generated files so team-wide .gitignore remains clean.

Diagnose Plugin and Theme Cost

Temporarily disable all plugins and switch to a minimal prompt. Re-enable components one by one to identify expensive parts.

zsh
1# temporary debug shell
2autoload -Uz promptinit
3promptinit
4prompt off
5
6plugins=()
7source ~/.oh-my-zsh/oh-my-zsh.sh

If performance returns, your original theme or plugin stack is the issue, not zsh itself.

Structured Performance Tuning Plan

Treat prompt slowness as a profiling task. First, capture baseline prompt latency in the problematic repository. Then disable theme git segments and measure again. Next, disable plugins incrementally to identify expensive hooks. If latency remains high, focus on repository characteristics: count untracked files, inspect submodule state, and check whether large generated directories are excluded. In monorepos, consider using a lighter prompt that avoids per-command git status scans. You can still keep branch name display while turning off dirty-state computation. Keep tuning changes in a documented shell profile section with comments describing why each setting exists. This makes future debugging easier when teammates reproduce the same issue on different machines.

bash
1# quick profiling helper
2for i in 1 2 3 4 5; do
3  /usr/bin/time -f '%E' git status --porcelain=v1 -uno >/dev/null
4Done

Verification Checklist

After each tuning change, measure prompt latency in both large and small repositories. Keep a tiny benchmark script in your dotfiles repository so performance regressions are easy to detect after shell or plugin upgrades.

Long-Term Maintenance Tip

Treat shell performance settings as part of your developer platform baseline. Keep tuned .zshrc defaults in a shared template and document repository patterns that trigger slow prompts, such as huge generated folders or many nested submodules. When teams onboard new machines, they start from a known fast setup instead of rediscovering the same tuning steps.

Common Pitfalls

  • Adding many plugins without measuring prompt impact.
  • Running in repos with huge untracked directories that should be excluded.
  • Assuming shell slowness is global when it is repo-specific git metadata cost.
  • Turning on advanced prompt features in large monorepos without fallback rules.

Also keep your shell startup lean by loading heavy integrations lazily. Prompt responsiveness improves when expensive setup runs only when required, not on every shell start.

Summary

  • Measure prompt and git status performance directly.
  • Disable expensive prompt git checks and unnecessary plugins.
  • Optimize repository state with excludes and git performance settings.
  • Isolate theme and plugin cost through binary-style re-enable testing.
  • Keep prompt behavior simple in very large repositories.

Related reading
Course
Intermediate
27 lessons
15 hours
DSA Fundamentals

Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Data Structures & Algorithms practice on Codemia

Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.

Practice algorithms

All Rights Reserved.