-
-
Notifications
You must be signed in to change notification settings - Fork 979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Git stash support #462
Conversation
If we decide to accept this, it should at minimum be opt-in using Alternatively, #460 could allow you do add this yourself without having to fork Pure. |
@mafredri Are you ok with adding this as opt-in through zstyle? |
I think that would be alright. So would we have an env variable for configuring the icon, and a zstyle for enabling the feature? Or should we take this opportunity to start defining icons in zstyle as well? |
Yes |
@carhartl Can you make it use zstyle? |
@sindresorhus Need to learn more about that but happy to try... |
@sindresorhus So it‘s supposed to be implemented as @mafredri suggested: zstyle for enabling the feature ? |
Using vcs_info's misc via hook to populate information about whether current directory has stashes...
f372b09
to
e9df830
Compare
I think it would be better to migrate all of the icons to zstyle, not just the one for stashes. This seems out of scope of this PR and I'd like to do this in a follow-up PR. |
👍
👍 |
Showing the stash status does now require opt-in via Is there anything else needed for this to be merged? |
Hmmm, might be nicer if we‘re not setting up the hook in the first place unless opted in! |
readme.md
Outdated
|
||
Showing git stash status as part of the prompt is not activated by default. To activate this you'll need to opt in via `zstyle`: | ||
|
||
`zstyle ':prompt:pure:git:stash:show' enable yes` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show and enable sounds a bit repetitive to me. Could it make sense to drop :show
here? Or drop show and rename enable => show.
pure.zsh
Outdated
# and stash information via misc (%m). | ||
zstyle ':vcs_info:git*' formats '%b' '%R' '%a' '%m' | ||
zstyle ':vcs_info:git*' actionformats '%b' '%R' '%a' '%m' | ||
zstyle ':vcs_info:git*+set-message:*' hooks git-stash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally I’d like us to avoid “doing the work” for gut stash, unless it’s enabled. But it’s not critical for this PR and we cam change it afterwards.
zstyle ':vcs_info:*' max-exports 4 | ||
# Export branch (%b), Git toplevel (%R), action (rebase/cherry-pick) (%a), | ||
# and stash information via misc (%m). | ||
zstyle ':vcs_info:git*' formats '%b' '%R' '%a' '%m' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m guessing there are no repercussions from including %a
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason it was producing an error when formats
didn't have the same amount as actionformats
. I really don't understand why these two seem to interact, maybe I did something wrong elsewhere, still new to zsh internals.
EDIT: not an error, but something that looked like an error, but was just not the expected output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, it’s been a while since I worked with vcs_info as well so just being cautious 😄. It’s probably fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a second look... %m
was only required in formats
only, but not in actionformats
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. How about when a git rebase is active? That’s when action formats kick in AFAICR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the actionformats are for when git is performing a merge or rebase. If I understand all this correctly, if we were omitting %m
from actionformats, info[stash]=$vcs_info_msg_3_
would remain empty (?) and the stash symbol would never be shown during such an action. Which is what we want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we need to ensure that $vcs_info_msg_3_
would always point to the expected output...
Can we make it |
Looks like we all had a few of the same ideas 😅 |
be ok? Or maybe |
That’s ok because there can be multiple values under a
This could also work. For me the former feels a bit more uniform but this is essentially a matter of enabling / disabling showing of git features so |
Ah, please bear with me... I missed to think of This changes everything :) Then I also think we should go for
Updating the commit... |
0a0f3d0
to
3fb7fe0
Compare
Is there anything you need me to add? |
I would love to see this merged, thanks for adding it. |
@@ -70,7 +70,11 @@ prompt pure | |||
| **`PURE_PROMPT_VICMD_SYMBOL`** | Defines the prompt symbol used when the `vicmd` keymap is active (VI-mode). | `❮` | | |||
| **`PURE_GIT_DOWN_ARROW`** | Defines the git down arrow symbol. | `⇣` | | |||
| **`PURE_GIT_UP_ARROW`** | Defines the git up arrow symbol. | `⇡` | | |||
| **`PURE_GIT_STASH_SYMBOL`** | Defines the git stash symbol. | `≡` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in the comments, this should be zstyle ':prompt:pure:git:stash' icon S
.
@carhartl Sorry, this fell off my radar. There are some remaining feedback: |
Oh, ok. Regarding the icon configuration I thought you agreed that this would be out of scope and would better be done for all icons instead of just this new one in a separate PR. See #462 (comment) |
Forgot about my comment. Never mind the zconfig thing then. |
Regarding the other issue: I had already changed it to
but it looks like I overlooked to adapt that in one place in the readme. |
f8f5a0d
to
d5f3c7d
Compare
@sindresorhus I have fixed the issue in the readme... |
Looks good. Thanks for working on this 🙌 |
This is adding support for git stashes. E.g. if there are any stashes show an icon, otherwise not (similar to how git arrows behave). Said icon is configurable via
PURE_GIT_STASH_SYMBOL
environment variable.It's implemented utilizing
vcs_info
'smisc
message + hook for tracking information about stashes.Please take this as a proposal I guess; while #365 is still open, I'm aware of the discussion in #317..