ohmyzsh: Oh My Zsh hangs because of slow `git status` calls
Describe the bug
Oh My Zsh makes my terminal hang after a command completes in Linux. I also found this Linux forum post which helped me confirm that Oh My Zsh is the culprit.
This happens to me on a Ubuntu VM inside Virtualbox, but it may generalise to non-VM setups. In my VM I have a project/ folder, in which I have mounted a very large data/ folder (34GB). This problem only happens when the folder is mounted.
Whenever I cd to the project folder / any of its subfolders (not necessarily the data folder), or run a command (eg ls), the command completes but my terminal hangs for a very long time (around the same amount of time it took for the directory to mount…). If I hit Ctrl + C then the terminal stops hanging and the command has completed, but the zsh prompt is just ->.
When I uninstall Oh My Zsh, the issue dissappears. Experimentation shows that I get the issue when I mount my directory with vboxsf or via my network with SMB, but not when the data exists directly inside my VM. Oh My Zsh must be doing something with those mounts after each command…
To Reproduce
- Run Ubuntu VM (e.g. Virtualbox)
mounta large volume to the VM (E.g. withvboxsforSMBvia a network share)cdto the parent directory of that volume- Wait a long time for the command to finish
Expected behavior
Shell becomes responsive after commands finish, like in normal zsh.
Desktop (please complete the following information):
- OS / Distro: Ubuntu VM inside Virtualbox
- Latest ohmyzsh Update?: Yes
- ZSH Version: Latest
- Terminal emulator: Any
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (5 by maintainers)
@JulianFerry Instead of hiding untracked files entirely via
git status -uno, I suggest another workaround. In git.zsh line 9, add atimeout [duration]prefix, like the following:This way, dirty git folders can be highlighted properly, as long as it doesn’t hang the terminal. 😃
You can modify the
__git_prompt_gitfunction in your zshrc file:Just to bump this thread: Do the
ohmyzshdevelopers think this is worth addressing? Perhaps by including thegitmessage:Confirmed on VM Player! : )
It’s such a relief to have that fixed. Thanks