caiogondim / bullet-train.zsh

:bullettrain_side: An oh-my-zsh shell theme based on the Powerline Vim plugin
MIT License
2.82k stars 383 forks source link

Hide git prompt completely if git config flag "oh-my-zsh.hide-status" is set #184

Closed grensjo closed 7 years ago

grensjo commented 7 years ago

Currently, when handling large git repositories on weak machines, generating the prompt can be really slow. For most oh-my-zsh themes, a good workaround is to manually set the "oh-my-zsh.hide-status" git config flag, which causes the git_prompt_info function to do nothing.

However, bullet-train does some extra work besides calling git_prompt_info. Therefore, setting this flag causes the git part of the prompt to be only partially hidden, and there is still an annoying delay. This should be fixed.

I have tested this fix successfully on my machines, and the check is basically the same as in Oh My Zsh (see https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/git.zsh#L4).

dawikur commented 7 years ago

Why not simply set BULLETTRAIN_GIT_SHOW to false? Or remove git segment entirely? (see #188). Won't the effect be the same?

reaktivo commented 7 years ago

@dawikur Can the BULLETTRAIN_GIT_SHOW flag can be set on a specific directory?

dawikur commented 7 years ago

@reaktivo Unfortunately not, it ~is~ was global setting (which was removed in #188). What is your use case?

reaktivo commented 7 years ago

Same use case as @grensjo, I have a few git repositories where I want to completely disable any git status checking since it takes around 4 seconds, but ideally would like to only disable it for this directories and not globally.

caiogondim commented 7 years ago

I'm not a big fan of having too different ways to configure a similar feature, but I see the value. I worked on a big git repo as well, and it took quite a while too show the prompt. I vote for merging that in.

dawikur commented 7 years ago

I see the point of it. Setting it per-repo might be a useful feature. We should only add comment about it to README so it would not be a hidden feature.

caiogondim commented 7 years ago

What I don't like is that, for doing the same thing for, let's say, mercury, that would be a different process.

grensjo commented 7 years ago

Well, this is a built-in oh-my-zsh feature, and right now Bullet Train is incompatible with it. If the "oh-my-zsh.hide-status" is set in a git repo, the git info is currently partially visible with Bullet Train, which is clearly not desirable behavior.

Bullet Train should either show the git info in its entirety, or do as oh-my-zsh itself and hide it if the flag is set. Since the latter option is consistent with how other themes behave, and since it is a nice feature, I think that is the better option.

I agree that it is not optimal that this only works for git, but since we're talking about a repo-level config it is probably difficult to make this more general in a good way. Either way, since the behavior is already partially there it makes sense to just fix this. If the feature is wanted for mercurial as well, I'm sure it's possible to do something similar there, but that is another issue.

caiogondim commented 7 years ago

👍 Still think it should be merged.

caiogondim commented 7 years ago

@grensjo Can you add documentation to README so I can merge your PR?

grensjo commented 7 years ago

@caiogondim Done!