romkatv / powerlevel10k

A Zsh theme
MIT License
46.61k stars 2.19k forks source link

[Feature Request] Only show git prompt in home root when it's dirty #1632

Closed ElSamhaa closed 3 years ago

ElSamhaa commented 3 years ago

The title pretty much sums it up. I want to detect any changes to my dotfiles that aren't in sync with remote.

romkatv commented 3 years ago

You can do that by editing my_git_prompt in ~/.p10k.zsh. It's fairly straightforward.

ElSamhaa commented 3 years ago

@romkatv you mean my_git_format?

romkatv commented 3 years ago

It's my_git_formatter. A function.

ElSamhaa commented 3 years ago

@romkatv I'm not sure how would you do that!

I want to satisfy this criterion:

I'm having a look at my_git_formatter rn, but are you suggesting that I should remove ~ from POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN and check the directory under the my_git_formatter?

romkatv commented 3 years ago

are you suggesting that I should remove ~ from POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN and check the directory under the my_git_formatter?

yes

ElSamhaa commented 3 years ago

@romkatv I looked at the p10k.zsh file, and sadly I don't think that this requirement can be applied from there.

The closest capability I found there to what I need is DIR CLASSES, but it just customizes the colors of the prompt.

romkatv commented 3 years ago

Have you tried https://github.com/romkatv/powerlevel10k/issues/1632#issuecomment-965683251? What was the problem with this approach?

ElSamhaa commented 3 years ago

The script is very declarative -- kudos, so unless the case is captured in a flag, there is not much to be done there.

In other words, I can't figure out how to check for the different conditions under that script, not just the aforementioned function. Maybe we need to have a look at another relevant script.

I need to check:

romkatv commented 3 years ago

CWD is $PWD. Status of the git repo is available through these: https://github.com/romkatv/powerlevel10k/blob/f217e4a39a284f6db7be7a4cfde8647085f97865/gitstatus/gitstatus.plugin.zsh#L90-L133

romkatv commented 3 years ago

Closing because I believe I've answered all questions here. As per FAQ, customizing git prompt requires editing my_git_formatter.