zimfw / git-info

Exposes git repository status information to prompts.
MIT License
6 stars 4 forks source link

Add support for more contexts #4

Open couloum opened 1 month ago

couloum commented 1 month ago

I suggest this PR to add support for the following new contexts:

These contexts are only available when verbose is set to yes.

I used the same code letters than original prezto/git module for a better compatibility.

With this PR, we can have more information on the 'dirty' state as we now see the different reasons of why a repo is dirty.

Example of prompt:

#  zstyle ':zim:git-info' verbose 'yes'
#  zstyle ':zim:git-info:branch' format "%F{white}%b%f"
#  zstyle ':zim:git-info:clean' format "%F{green}✔%f"
#  zstyle ':zim:git-info:dirty' format "%F{red}≠%D%f|"
#  zstyle ':zim:git-info:added' format "%F{white}✚%a%f"
#  zstyle ':zim:git-info:deleted' format "%F{white}✖%d%f"
#  zstyle ':zim:git-info:modified' format "%F{white}●%m%f"
#  zstyle ':zim:git-info:untracked' format "%F{white}?%u%f"
#  zstyle ':zim:git-info:renamed' format "%F{white}r%r%f"
# zstyle ':zim:git-info:keys' format \
#   'status' '(%b|%C%D%a%m%d%r%u)'
(main|≠5|✚1●1✖1r1?1)
ericbn commented 1 month ago

Hi @couloum. I know these context exist in prezto's git-info, but I think it's too much information and I prefer to keep it simple, like we try to keep it simple in zimfw.

(I was considering adding an unmerged context, so files with merge conflict show up in this context instead of both indexed and unindexed, but I'm still thinking it twice and didn't implement it yet.)

Any new context need to be used in at least a couple of our themes for it to make sense. Of course all these context proposed here could be added to the sorin theme. But I specially like how our fork of sorin is less poluted with symbols than the original prezto version.

EDIT: Also, these new context require the verbose mode, which makes the prompt slower when enabled, so we try to avoid it. In fact, only our forks of the steeef and sorin themes use it.

couloum commented 1 month ago

Thank you for your prompt answer. I understand the philosophy to have minimal and non-bloated framework. I currently use prezto and consider using zimfw especially for that. I do have created my own prompt in prezto that do contains these contexts. Therefore I added them for myself and suggested a PR to have this integrated mainstream. But I can leave with my own fork. It just felt to me that it was not a big addition considering that there's no additional command executed by the module. I didn't do benchmarks, but I would say that performance impact is negligible. And nobody is forced to use these. It's just a feature available for anyone wanting to use that their custom themes.

I let you decide whether or not you should validate this PR.

ericbn commented 1 month ago

I'll leave this open to see if there's any interest in it.

You can always use prezto's git-info instead of ours with:

.zimrc

zmodule sorin-ionescu/prezto --root modules/git
zmodule git

.zshrc (on top)

zstyle ':prezto:module:git:alias' skip 'yes'