Powerlevel9k / powerlevel9k

Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
https://github.com/romkatv/powerlevel10k
MIT License
13.47k stars 947 forks source link

Change "POWERLEVEL9K_VCS_GIT_HOOKS" for specific repository #1133

Closed SebTM closed 5 years ago

SebTM commented 5 years ago

Thank you very much for this awesome theme!

I'm using powerlevel9k around one and a half year and some weeks ago I got into trouble I think because of an update or something. My terminal got stock for a few seconds every time after I executed a command - like change directory.

After researching some performance issues in this repository, I found out that the problem is the "git-untracked" which is registered in "POWERLEVEL9K_VCS_GIT_HOOKS". In my home-directory I have a git repository holding my Dotfiles, there are also (many) other untracked files but in the past it was no problem as I changed "status.showUntrackedFiles" to no for this repository.

Is it possible to disable only "git-untracked" for this specific repository?

dritter commented 5 years ago

Hi @SebTM ,

this is really interesting. Some weeks ago we changed the way the vcs segment works because of performance reasons. We did some measurings which I would ask you to do as well, and post the output here. Maybe we did something wrong in certain cases.

To answer your question, this is not a built-in feature of P9K at the moment, but there is a workaround.

SebTM commented 5 years ago

Hey @dritter,

thanks for the fast reply. I did the measurement you asked me for (with branch "next" - pulled today), here are the results:

git status

( repeat 10; do; command git status --porcelain > /dev/null; done; )
0.05s user 0.05s system 79% cpu 0.128 total

git ls-files

( repeat 10; do; command git ls-files --others --exclude-standard > /dev/null)
4.38s user 9.23s system 99% cpu 13.677 total

VCS segment new

( repeat 10; do; prompt_vcs left 1 false > /dev/null; done; )  
10.39s user 10.26s system 99% cpu 20.742 total

VCS segment old

( repeat 10; do; prompt_vcs left 1 false > /dev/null; done; )
10.88s user 10.85s system 99% cpu 21.776 total

Do I need to place the workaround in my ".zshrc"? Should it appear before or after I load the theme with zplug?

dritter commented 5 years ago

Yep. The workaround should be placed in your .zshrc.

This is really interesting. In my measurements the git ls-files variant was faster. Could you describe your system a bit more? Do you have a SSD or a spinning disk? Which git version do you use? Which OS do you use?

Btw. did you actually switch commits between measuring the old and new vcs segment?

SebTM commented 5 years ago

Thanks for your reply and the workaround! One problem - the "special Directory" is my home-dir and the workaround just works after I left the directory and rejoin it. Is there any "quick fix" for that?

My Laptop Specs are: MacBook Pro (15", 2016) - i7 - 16 GB RAM - 500 GB SSD MacOS Mojave (10.14.2) Git is installed through homebrew in the latest (there) available version (2.20.1)

No, I didn't switch - I was at the latest next-branch for all measurements.

dritter commented 5 years ago

the "special Directory" is my home-dir and the workaround just works after I left the directory and rejoin it. Is there any "quick fix" for that?

Well, the easiest fix would be just to call that function directly from your ~/.zshrc, because at this point you know that you are in your home folder..

I am still puzzled about the performance regression.. You changed your PATH to include the homebrew-installed binaries first, right? Otherwise VCS_INFO would run with OSX version of git.

SebTM commented 5 years ago

Okay, perfect this works for now 👍

I think everything is right there - here you can verify this details yourself:

screenshot 2019-01-20 at 22 36 11
SebTM commented 5 years ago

Changed my way of handling Dotfiles to not have this amount of untracked files and to get rid of the improvement :)