Ohmyzsh: vi-mode plugin makes zsh painfully slow in OSX Mavericks

Created on 23 Oct 2013  ·  51Comments  ·  Source: ohmyzsh/ohmyzsh

in .zshrc:

plugins=(vi-mode)

zsh is now extremely slow

plugins=()

zsh now behaves normally

All 51 comments

I can confirm - disabling vi-mode made console responsive again.

same here

Seeing the same behavior. Either of this lines from the vi-mode.plugin will cause the slowdown:

zle -N zle-line-init
zle -N ale-line-finish

+1 on this, just discovered this as well.

Same here. Although I thought it was the theme at first, I commented out ZSH_THEME and its fast again. Then I tried turning off vi-mode and turning on ZSH_THEME and it is still fast. There's something about these two.

Had the same issue, it makes the shell completely unusable with vi-mode enabled

Did some troubleshooting and found the same as @poymode last night. Looks like the issue happens when calling:

zle reset-prompt

Based on the ZLE docs here, the prompt is redrawn when reset-prompt is called. I found that commenting out zle reset-prompt eliminated the slowness as did commenting out the logic that grabs data from git to display in the prompt. This leads me to think that the calls to git are a bit slower in Mavericks than they used to be causing the prompt rewriting to slow down. Im not certain about this, though. I just don't have the zsh skills to debug this further. Is there anyone that can take this debugging further?

I updated git to 1.8.4.1 and enabled vi-mode again, seems to fix the responsness for me

I removed the git under directory /usr/bin and installed git v1.8.3.2, back to normal now.

Or just comment
zle -N zle-line-init
zle -N zle-line-finish
zle -N zle-keymap-select
in vi-mode.plugin.zsh also works.

Same problem here. I did notice that the terminal title switched to xcodebuild during the delay in processing each command.

I have disabled the plugin, and simply put bindkey -v into my .zshrc for now.

Same here. Disabling vi-mode plugin does the magic. Any one wants to commit a fix?

same here. comment following lines in ~/.oh-my-zsh/plugins/vi-mode/vi-mode.plugin.zsh to fix this

le -N zle-line-init
zle -N zle-line-finish
zle -N zle-keymap-select

Using an updated git also fixed it for me. The Apple version of git seems to cause the problem, I installed git from homebrew instead.

Confirmed that it works with upgraded git-1.8.4.1.

:+1: installing git from homebrew fixed this. I saw the terminal title flick from xcodebuild to git from time to time. I wonder what Apple's git is doing?

same problem, thanks~

Same problem with vi-mode, but running Git installed from Homebrew (1.8.4.2, symlinked to /usr/local/bin/git).

Also seeing xcodebuild in my Terminals title while executing commands.

@cseelus I would double check that your path leads to homebrew's git before Apple's git

git --version or which git should answer the question

@sschlesier before posting, i did this:

    $ which git
    /usr/local/bin/git

    $ git --version
    git version 1.8.4.2

Switching to homebrew git makes zsh generating new prompt faster but still not quite fast as in the case I remove git / vi-mode plugin

+1, same issue.

+1

the output command ls dissapear on dotfiles directory

UPDATE:
Fantastic! It seems like Apple's git was the culprit. I was running 1.8.3.4 when I was having the lag issues. I installed brew git (version 1.8.5.2) and all lag issues have been fixed.

I have run into a similar issue, although I am not using the vi-mode plugin like most other people here. I am using oh-my-zsh with the agnoster theme (although I have tested this with other themes and the same thing happens. I believe the use of git for the prompt is the common factor here). The command line is only very slow when I am inside of a git repo. I have added "bindkey -v" to my own personal vim.zsh file inside of ~/.oh-my-zsh/lib/. Inside of this file I also have this small bit of code that visually shows which mode zle is currently in.

function zle-keymap-select zle-line-init {
# these are used to indicate on the right side of the prompt
RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}"
zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select

My belief is that git and "zle reset-prompt" are not playing well together. Every time "zle reset-prompt" is called, git is being used again to redraw the prompt, which I believe is the root of all of this lag. Removing "zle reset-prompt" fixes any kind of lag. I'm not sure of a workaround yet but it is quite frustrating because vi mode in zsh is a pain in the ass to use without some kind of visual indicator of the current mode.

I am currently trying to install a newer version of git and will report back with any changes.
Note: I'm on Maverick 10.9.1

I'm on Mavericks 10.9.1 too, using vi-mode as well, and I had this issue. I was originally using Apple's git, and I can confirm that just by switching to homebrew's git fixed the issue.

had to comment out the following line in my antigen.conf

antigen-bundle vi-mode

zsh is super fast now. BTW, this is on Mavericks 10.9.1.

brew install git fixed it for me, it did have to do with the git version bundled with my mac.

I'm on OS X 10.9.2, using vi-mode plugin, using git plugin, displaying git_prompt_info on RPROMPT, and using Apple's git.

I encountered this issue. Updating git to v1.9.0 via brew install git fixed it. Thanks!

removed vi-mode
added bindkey -v

that fixed it for me

@bradtse Having the same issue. Commenting out reset prompt removed the problem lag when inside a git repo. Current GIT version is 1.9.1 but the unfortunately the problem still exists.

Still an issue.

Apple's git on my machine was version 1.8.5.2 (Apple Git-48), so it seems to be an xcode thing, not strictly a version thing.

Did brew install git (installed version 1.9.2) and changed my path so /usr/local/bin comes before /usr/bin. Now vi-mode works with no delay.

Same thing here, even a simple bindkey -v make the shell really sluggish.

git version: 2.0.1
OSX: 10.10 dp3

On OSX 10.9.4, using zsh and Git (git version 1.8.5.2 (Apple Git-48)). The following fixed the slow down:
Edit .oh-my-zsh/plugins/vi-mode/vi-mode.plugin.zsh
On line 13, comment out zle reset-prompt.

I only have git and vi-mode as plugins in .zshrc

+1 for updating Git! I just ran brew install git && exit, opened up a new iTerm2 window, and it was fixed.

+1, updated Git and now... it's awesome.

I didn't have this issue on OS X 10.9 (Mavericks); but I am seeing it after upgrading to OS X 10.10 (Yosemite).
Doing a brew install git and making sure /usr/local/bin is in the PATH before /usr/bin fixed it for me.

+1 for Yosemite and the Apple Git 1.9.3. Installing Git with brew fixes the sluggishness.

Perhaps someone should close this issue and edit the original post to contain the fix? After solving this problem months back and forgetting about it, I just got set up on a new imac and was dealing with the painful slowness again. Googled and found this issue again – brew install git is the solution.

Including this information in the first post will save future googlers the effort of reading the first half of this thread and the "me too"s before someone suggests the correct solution.

+1 more confirmation that the brew version of git fixes slowness on Yosemite

If you hit this...

brew install git

OMG, forgot about this and it was driving me nuts on a laptop I just configured :)

Switching to homebrew's Git resolved this for me as well, but I'm curious why. Anyone have an idea as to why Mac's pre-rolled version of Git is giving ZSH so much trouble?

Tested in Yosemite (10.10.3), installing git 2.4.3 with brew, same great results :+1:

+1 to installing git 2.4.3 homebrew.

Same problem in 10.11 too; don't use Apple's version of git

Experienced the same issue in El Capitan 10.11. Installing git using brew solved the problem.

+1 Fixed on OS X 10.9.5 Mavericks by replacing native Apple Git 1.9.3 with Git 2.5.1 from homebrew.

+1 Fix for brew install git

This also fixed my issue, but wouldn't it be better to add a command to zsh that would allow the functionality for vi-mode but not reset every plugin in the process (eg. git)?

I also encounter same problem, my environment is

Yosemite 10.10.5
Git 2.3.2 (Apple Git-55)

I only use git and vi-mode plugin, I fixed it by comment a line in .oh-my-zsh/plugins/vi-mode/vi-mode.plugin.zsh

zle reset-prompt

I also encounter same problem, my environment is

Yosemite 10.10.5
Git 2.3.2 (Apple Git-55)

I only use git and vi-mode plugin, I fixed it by comment a line in .oh-my-zsh/plugins/vi-mode/vi-mode.plugin.zsh

zle reset-prompt

not perfect but 100% faster switch between the vi-modes...
(under WSL Ubuntu on Windows 10 1809)

Was this page helpful?
0 / 5 - 0 ratings