Pure: git stash

Created on 13 Nov 2017  Â·  8Comments  Â·  Source: sindresorhus/pure

I read the discussion in Issue #317 and understand the concern to not have a messy prompt. The right prompt suggestion is a decent workaround but the problem is that shows a message when there are no changes in stash. For a light user of stash, the constant 0 in the right hand side of the screen is a distraction. Changing that requires building a function that indicates it may be more appropriate.

I use stash to store work in progress changes that I don't want to commit before I re-integrate master into my branch. It's useful to see an indicator if there are changes in stash I forgot about if I get interrupted in my workflow. I used a custom prompt that someone at work shared around that used something like * to indicate there is something in your stash.

Would it be a good compromise to add the stash indicator functionality but set a default minimum threshold before there is an indicator that could be changed with an environment variable? For example, the default could be a high number, say. Those who are light stash users could override that and set it to 0.

The alternative is to create a super light "pure-stash" indicator that is separate from pure.

Most helpful comment

I'd love to see support for stashes... at the moment I've hacked something into prompt_pure_preprompt_render() on my own machine, the result looking like:

screenshot 2019-02-08 at 19 05 37

If there are any stashes, the yellow ≡ icon is shown, otherwise not... (similar to how in and outgoing arrows behave)

(I would be happy to prepare a PR for this.)

PS: Icon and color is inspired by https://github.com/michaeldfallen/git-radar, which I recently migrated from to pure...

All 8 comments

@leoj3n I'm curious on your thoughts since you opened the original issue.

Alternatively, is it possible to allow calling some custom function for displaying git information? Where I still want to use the rest of pure prompt, but insert my own git information.

I'd love to see support for stashes... at the moment I've hacked something into prompt_pure_preprompt_render() on my own machine, the result looking like:

screenshot 2019-02-08 at 19 05 37

If there are any stashes, the yellow ≡ icon is shown, otherwise not... (similar to how in and outgoing arrows behave)

(I would be happy to prepare a PR for this.)

PS: Icon and color is inspired by https://github.com/michaeldfallen/git-radar, which I recently migrated from to pure...

Might be even nicer to have the icon the same color as the arrows, though I'm not a designer :)

Here's the implementation: https://github.com/sindresorhus/pure/compare/master...carhartl:git-stash-support

It would need some polishing I guess, making the icon configurable (similar to the arrows) and so on.

For what it's worth, in my version of git-aware-prompt I only show the stash indicator if the top stash was made on the current branch (or on the current commit).

That suits my workflow, because it doesn't distract me when I am working on a different branch, but when I switch back to the branch where I originally stashed, the indicator appears, reminding me I need to pop. To reduce clutter, you may consider implementing the feature that way. Code is here but not beautiful!

I read the discussion in Issue #317 and understand the concern to not have a messy prompt. The right prompt suggestion is a decent workaround but the problem is that shows a message when there are no changes in stash. For a light user of stash, the constant 0 in the right hand side of the screen is a distraction. Changing that requires building a function that indicates it may be more appropriate.

See https://github.com/sindresorhus/pure/issues/317#issuecomment-529947677 for a Q&D hack.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ebsen picture ebsen  Â·  10Comments

sbmueller picture sbmueller  Â·  11Comments

opticalgenesis picture opticalgenesis  Â·  9Comments

lezuber picture lezuber  Â·  11Comments

erusev picture erusev  Â·  4Comments