Skip to content
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 segment to display number of stashes, if any #201

Closed
wants to merge 1 commit into from
Closed

Add git_stash segment to display number of stashes, if any #201

wants to merge 1 commit into from

Conversation

apinkney97
Copy link
Contributor

Addresses issue #114

phatblat added a commit to phatblat/powerline-shell that referenced this pull request Nov 17, 2015
@phatblat
Copy link
Contributor

👍 Just tested this out and it looks good. One suggestion: add spaces on either side of the stash count text to match the style of other segments (last 2 prompts in screenshot).

screen shot 2015-11-16 at 8 46 41 pm

See phatblat/powerline-shell@74552cb

@apinkney97
Copy link
Contributor Author

Sure, if you think it looks better. I removed them to stop the segment being too wide, but I guess we could lose the parentheses instead. Perhaps spaces on either side but with a trailing 's' or asterisk to denote that it's stashes rather than commits ahead/behind (which is why I parenthesised it in the first place).



def add_git_stash_segment():
stash_count = subprocess.check_output('git stash list | wc -l', shell=True).strip()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing the line count in Python may be more efficient. Would be interested in seeing if that were true.

@b-ryan
Copy link
Owner

b-ryan commented Nov 19, 2015

A few new icons were added in #136. I wonder if we should add a new one for this as well rather than the parentheses. The asterisk no longer will work since that is being used to denote conflicts. Another change that could make this align with #136 would be to show only the icon when there is one stash and a number with the icon when there is more than one stash.

@apinkney97
Copy link
Contributor Author

I'll have a look at reworking this in light of the changes in #136. I think I'll close this and open a new pull request once it's done.

@apinkney97 apinkney97 closed this Nov 19, 2015
@apinkney97
Copy link
Contributor Author

I have had a quick glance at some potential unicode glyphs to represent stashes:
u'\u2398' ⎘
u'\u2295' ⊕
u'\u24c8' Ⓢ

I'm leaning towards \u2295 (circled plus). If you have something better in mind, let me know.

@phatblat
Copy link
Contributor

I like the first one (next page) the best out of these. The "circle s" one seems too big.

screen shot 2015-11-19 at 10 10 52 am

The last two glyphs:
u'\u21AF' ↯(zigzag arrow)
u'\u2397' ⎗ (previous page)

@b-ryan
Copy link
Owner

b-ryan commented Nov 19, 2015

Agreed that the S is too big. The next/previous page are also my favorite of these.

@apinkney97
Copy link
Contributor Author

I'm happy with 'next page'.

Do you have any preferences on colours? At the moment I've got

GIT_STASH_BG = 221
GIT_STASH_FG = 0

which looks like
stash

@b-ryan
Copy link
Owner

b-ryan commented Nov 22, 2015

I don't, really. What you came up with looks fine. I think once I'm using it, maybe I'll have more of an opinion.

@uloco
Copy link

uloco commented Mar 18, 2018

Did there ever happen any pull request regarding this issue? Would be happy to have this feature... Really forget my stashes all the time -.-

@apinkney97
Copy link
Contributor Author

Nope, I totally forgot about this (but shamefully have been using it myself for the past 2.5 years)

The segment code looks to have changed a little since I wrote this, so I'll redo it in the updated style and submit a PR soon (I promise ;))

@apinkney97
Copy link
Contributor Author

@b-ryan would your preference be for this to be a new segment (as suggested in the original issue, #114) or to be added to the existing git segment?

Ultimately all this does is call git stash list and count the lines, so should not add much overhead. Also, it would be pretty trivial to allow the stash count to be disabled via config if the user doesn't care about it.

@phatblat
Copy link
Contributor

@apinkney97 The git stash call is extra overhead because it's launching a new process and that adds a few milliseconds of delay before the prompt shows up. This is how most of the git segments work now, but each one is adding a few more milliseconds.

I never got around to looking into using something like pygit to do these git lookups in the same process.

@apinkney97
Copy link
Contributor Author

Ok, I'll probably add it as a new ThreadedSegment in that case.

@apinkney97 apinkney97 mentioned this pull request Mar 20, 2018
@b-ryan
Copy link
Owner

b-ryan commented Mar 20, 2018

Agreed with @phatblat :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants