Search code examples
gitzsh

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


I recently started using Zsh and it's awesome. Unfortunately, for the project I consider my "main" project, everything is slow. What I mean is that every time I run a command - ls, for example - there's about a five-second delay between the time the command is executed and the time I can use the terminal again.

What could be different about this one repo that makes Zsh so slow? I assume it's a Zsh-specific thing because there was no problem before I started using Zsh. I tried doing a git clean but it didn't make any noticeable difference.

I'm on Mac OS X if that matters.

Update: Turns out this line of my .zshenv is what was making it slow:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

If I comment that line, it goes from taking about 3 seconds to taking about 1 second. Unfortunately, I need that line, since many of my projects use RVM. I don't know what to do now.

Update 2: this seems to be specifically an oh-my-zsh thing. If I don't load ~/.oh-my-zsh/oh-my-zsh.sh, I don't have a problem.


Solution

  • You can add this to your git config and zsh won't check the status anymore

    git config --add oh-my-zsh.hide-status 1
    git config --add oh-my-zsh.hide-dirty 1
    

    Explanation

    There are two central git functions in in lib/git.zsh:

    • git_prompt_info()
    • parse_git_dirty()

    Each Method has a git config switch to disable it:

    • oh-my-zsh.hide-status
    • oh-my-zsh.hide-dirty

    Some themes create their own git queries and sometimes ignore these flags.