Oh-my-zsh slow but only for a specific git repo

I recently started using Zsh and it was awesome. Unfortunately, for the project I consider my "main" project, everything is going slowly. I mean, every time I run the command - ls , for example, there is about a five second delay between the time the command takes to execute and the time when I can use the terminal again.

What can be great in this repo that makes Zsh so slow? I suppose this is a Zsh-specific thing, because there were no problems before I started using Zsh. I tried to do git clean , but that didn't make any noticeable difference.

I am on Mac OS X, if that matters.

Update: It turns out this line of my .zshenv is what made it slower:

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

If I comment on this line, it will take from 3 seconds to 1 second. Unfortunately, I need this line, as many of my projects use RVM. I do not know what to do now.

Update 2 : this is apparently a special thing about -my-zsh. If I do not download ~/.oh-my-zsh/oh-my-zsh.sh , I have no problem.

+65
git zsh
Oct 07 '12 at 1:21
source share
9 answers

You can add this to your git config and zsh will no longer check the status

 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 lib / git.zsh :

  • git_prompt_info()
  • parse_git_dirty()

Each method has a git configuration switch to disable it:

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

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

+103
Sep 16 '14 at 8:32
source share

Oh_my_zsh seems slow for some repos because it checks the status of the repo after each command. This behavior can be changed in the new version of .oh_my_zsh. Just uncomment the following line in .zshrc:

DISABLE_UNTRACKED_FILES_DIRTY = "true"

After that, restart your terminal or do the following:

source ~ / .zshrc

+12
Aug 10 '16 at 6:22
source share

There are several ways to speed up oh-my-zsh , as described in the zsh section, it starts incredibly slowly , clearing the plugin section.

For example, the blog post Fix for oh-my-zsh git-svn prompt slowown mentions parse_git_dirty as a potential problem.

+10
Oct 08
source share

It could be a theme that calls git and rvm after each command.

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

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

+10
Jan 20 '13 at 7:10
source share

For me, this is slow on VirtualBox (guest) because I use a synchronized folder. I still want this to be enabled on OS X (host), where it is fast enough. Instead of using the local configuration parameter, which is stored in the repository and which will change it both on the guest and on the host machine, I use the global configuration parameter only on the guest :

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

If I want this for just one repo:

 git config --add oh-my-zsh.hide-dirty 1 
+7
Dec 03 '16 at 1:00
source share

I finally figured it out. My project had a rake folder with tons of files (e.g. 20,000). I have no idea what this folder was for, but I deleted it, Zsh no longer works more slowly, and my application still works.

+5
Feb 16 '13 at 18:54
source share

If you don't need other version control programs but git , you can simply disable all vcs_info in your *.zsh-theme and replace them with your own git commands.

For example, I configure agnoster.zsh-theme to:

  • comment / delete all lines with vcs_info ,
  • edit the code in prompt_git() from:

    ref="$vcs_info_msg_0_" to

    ref="$(git branch 2>/dev/null | grep -Po '(?<=\* ).*$')"

So basically, I just turned off all vcs_info actions and instead used my own git command to check repo statuses. As a result, I can still see the helpful git hint at a speed as fast as working in the git directory. With this small modification, my zsh can run 4-5 times faster with git repos.

Note: use GNU grep, not BSD grep.

+2
Dec 02 '17 at 9:51 on
source share

The answers above did not solve my problem. In my case, the git_prompt_status function takes too much time than others. So I changed ~ / .oh-my-zsh / lib / git.zsh, replacing the git_prompt_status function with my earlier return version:

 function git_prompt_status() { STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" echo $STATUS return local INDEX STATUS INDEX=$(command git status --porcelain -b 2> /dev/null) STATUS="" if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" fi if $(echo "$INDEX" | grep '^A ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" elif $(echo "$INDEX" | grep '^MM ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" fi if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" elif $(echo "$INDEX" | grep '^MM ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" fi if $(echo "$INDEX" | grep '^R ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS" fi if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" fi if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS" fi if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" fi if $(echo "$INDEX" | grep '^## [^ ]\+ .*ahead' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS" fi if $(echo "$INDEX" | grep '^## [^ ]\+ .*behind' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS" fi if $(echo "$INDEX" | grep '^## [^ ]\+ .*diverged' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS" fi echo $STATUS } 

Although I use ZSH_THEME_GIT_PROMPT_MODIFIED as a mark of uncertainty, you can choose any status you like to indicate this, or implement the much more git_prompt_status function git_prompt_status in your case.

0
Jul 15 '19 at 7:41
source share

Probably the easiest and most reliable workaround I could come up with is just to type

 bash 

I did this in a directory with my huge git repository and everything works fine.

-four
Jun 16 '17 at 17:57
source share



All Articles