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.

  • Using a caret(^) when using Git for Windows in PowerShell
  • Why am I getting a merge error when trying to pull from my repository?
  • How to display metainformation about single commit in git
  • How can I completely empty the master branch in Git?
  • Multiple Git repositories for each Eclipse project or one Git repository
  • .gitattributes default file type treatment
  • 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 the problem.

  • Force merge commit and fast forward in git-merge
  • How to push a new folder (containing other folders and files) to an existing git repo?
  • How can I sign each (even old) commit in the repository?
  • is this a valid git fork use-case?
  • Using Dropbox to synchronize files and having them backed up in version control
  • Changing local directory name to match github repository name change
  • 7 Solutions collect form web for “oh-my-zsh slow, but only for certain Git repo”

    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
    

    Detailed Answer:
    There are two central git functions (git_prompt_info() and parse_git_dirty()) in lib/git.zsh. Each Method has a git config switch to disable it
    (oh-my-zsh.hide-status and oh-my-zsh.hide-dirty)

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

    There are various way to speed up an oh-my-zsh, as detailed in “zsh starts incredibly slowly”, cleaning up the plugin section.

    For instance, the blog post “Fix for oh-my-zsh git-svn prompt slowness” mentions the parse_git_dirty function as a potential issue.

    It could be the theme calling git and rvm stuff after every command.

    For me, changing ZSH_THEME="juanghurtadoto" to ZSH_THEME="miloshadzic" removed the 2 second delay after every command completely.

    Themes can be found at https://github.com/robbyrussell/oh-my-zsh/wiki/themes

    Oh_my_zsh seems to be slow for some repos where the because it check the status of the repo after each command.
    This behaviour can be overridden in the new version of .oh_my_zsh .
    Just Uncomment the following line in .zshrc:

    DISABLE_UNTRACKED_FILES_DIRTY=”true”

    After this, restart your terminal or run the following:

    source ~/.zshrc

    I finally figured it out. My project had a rake folder with a ton of files (like 20,000). I have no idea what that folder was there for, but I deleted it, Zsh is no longer slow, and my app still seems to work.

    For me it’s slow on VirtualBox (the guest) because I’m using a synced folder. I still want it enabled on OS X (the host) where it’s fast enough. Instead of using a local config setting which is stored with the repo and would change it both on the guest and host, I use a global config setting only on the guest:

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

    If I want it just for a single repo:

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

    Probably the most simple and reliable workaround that I could come up with was to just type

    bash
    

    I did this in the directory with my huge git repository and everything works great.

    Git Baby is a git and github fan, let's start git clone.