geometry-zsh / geometry

geometry is a minimal, fully customizable and composable zsh prompt theme
ISC License
931 stars 94 forks source link

Git stash indication ? #199

Closed ev-agelos closed 6 years ago

ev-agelos commented 6 years ago

I am not sure if it is easy to be shown but would be useful if we could see an indication of stashes we have made in a repo.(a number of stashes or nothing to be shown maybe?)

My use case is that many times i forget that I have stashed something and I continue committing.

jedahan commented 6 years ago

I'd be open to a pull request that defines the following:

GEOMETRY_COLOR_GIT_STASHES=${GEOMETRY_COLOR_GIT_STASHES:-<what color?>}
GEOMETRY_SYMBOL_GIT_STASHES=${GEOMETRY_COLOR_GIT_STASHES:-<what symbol?>}

GEOMETRY_GIT_STASHES=$(prompt_geometry_colorize $GEOMETRY_COLOR_GIT_STASHES $GEOMETRY_SYMBOL_GIT_STASHES)
PROMPT_GEOMETRY_GIT_STASHES=${PROMPT_GEOMETRY_GIT_STASHES:-false}

prompt_geometry_git_stashes() {
  git rev-parse --quiet --verify refs/stash && echo $GEOMETRY_GIT_STASHES
}

Adds to geometry_prompt_git_render():

 if $PROMPT_GEOMETRY_GIT_STASHES ; then
    stashes="$(prompt_geometry_git_stashes)"
 fi

And modifies render+= to include ${stashes}

jedahan commented 6 years ago

Let me know if you'd like to take a stab at it, I'm kinda busy this week but can at least review test and merge a patch. We need to define a default symbol and color as well.

jedahan commented 6 years ago

Also there has to be a faster way to get if stashes exist or not

ev-agelos commented 6 years ago

Ill give it a shot in the weekend even though I am not expert on shell scripting!

jedahan commented 6 years ago

awesome!

git rev-parse --quiet --verify refs/stash seems to be the simplest command to find out if a stash exists

ev-agelos commented 6 years ago

Wasn't so difficult as I thought! Nice documentation with steps on how to do a plugin! I created this: https://github.com/ev-agelos/geometry-git-stashes I am confused a bit about how to make the PR. I see that the plugins live in their own repos and user explicitly includes them in their zshrc. (Also i don't have permissions to update the wiki)

Edit: I think I shouldn't have made it a plugin :S I mean it is a git thingy so it would be convenient to be bundled with the core? What do you think guys? And also the icon/color I tried to find something that makes sense but they are not geometric so if you think there is something better please tell me

frm commented 6 years ago

You can now edit the wiki 😄 See #200

frm commented 6 years ago

Closed by #201