Spaceship-prompt: Different colors for different git status

Created on 15 Mar 2018  Â·  6Comments  Â·  Source: denysdovhan/spaceship-prompt

Issue

Currently, it's only possible to distinguish the different git status by icon/symbols.
Icons feel more distracting than colors, and colors can be matched with the actual output of git status.

As a consequence, it would be valuable to have more fine-grained control over the colors in git.

See #375

good first issue help-wanted proposal

Most helpful comment

I've briefly dug out my previous zsh prompt to make a screenshot:
screen shot 2018-03-16 at 09 05 15

You can see the three dots in the right that mirror the colors of git status.
That is what I'd like to be able to do :)

I used the this character: https://www.fileformat.info/info/unicode/char/2022/index.htm

All 6 comments

Did you mean something like this ?

multi colored git status

I've briefly dug out my previous zsh prompt to make a screenshot:
screen shot 2018-03-16 at 09 05 15

You can see the three dots in the right that mirror the colors of git status.
That is what I'd like to be able to do :)

I used the this character: https://www.fileformat.info/info/unicode/char/2022/index.htm

I love the idea! Could you share the config that colorizes the output of git status itself?


Today it is possible to configure the spaceship icons too, it's a bit cumbersome, but possible 🙂

The approach is basically to set all the options using this format: %F{<new-color>}<icon>%F{<default-color>}

For example, choose the default color as red and do:

export SPACESHIP_GIT_STATUS_ADDED="%F{yellow}+%F{red}"
export SPACESHIP_GIT_STATUS_UNTRACKED="%F{blue}?%F{red}"
export SPACESHIP_GIT_STATUS_DELETED="%F{green}x%F{red}"
export SPACESHIP_GIT_STATUS_MODIFIED="%F{red}!%F{red}"

It looks like this:

image

If you want to use • as a character, just use it everywhere:

export SPACESHIP_GIT_STATUS_ADDED="%F{yellow}•%F{red}"
export SPACESHIP_GIT_STATUS_UNTRACKED="%F{blue}•%F{red}"
export SPACESHIP_GIT_STATUS_DELETED="%F{green}•%F{red}"
export SPACESHIP_GIT_STATUS_MODIFIED="%F{red}•%F{red}"

image

I think its just this:

[color "status"]
  added = yellow
  changed = green
  untracked = blue

I also have an alias for git s that is a bit more compact than git status:

[alias]
  s   = status -s -b

edit:
This is the setup that matches my git status:

SPACESHIP_GIT_STATUS_ADDED="%F{yellow}•%F{red}"
SPACESHIP_GIT_STATUS_UNTRACKED="%F{blue}•%F{red}"
SPACESHIP_GIT_STATUS_DELETED="%F{red}•%F{red}"
SPACESHIP_GIT_STATUS_MODIFIED="%F{green}•%F{green}"

But to make it clear, the preferred code fix would be to add the configurations below to the git_status section in addition to the existing SPACESHIP_GIT_STATUS_COLOR:

SPACESHIP_GIT_STATUS_COLOR_ADDED="${SPACESHIP_GIT_STATUS_COLOR_ADDED="$SPACESHIP_GIT_STATUS_COLOR"}"
SPACESHIP_GIT_STATUS_COLOR_UNTRACKED="${SPACESHIP_GIT_STATUS_COLOR_UNTRACKED="$SPACESHIP_GIT_STATUS_COLOR"}"
SPACESHIP_GIT_STATUS_COLOR_DELETED="${SPACESHIP_GIT_STATUS_COLOR_DELETED="$SPACESHIP_GIT_STATUS_COLOR"}"
...

We can also add SPACESHIP_GIT_STATUS_COLOR_AHEAD, "_BEHIND, and "_DIVERGED . These are usually in cyan and magenta.

Some OMZ themes show diverged branches by showing symbols for both ahead and behind (⇡⇣ instead of ⇕). This functionality can be supported by showing both of them if $SPACESHIP_GIT_STATUS_DIVERGED is empty.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oldchevy picture oldchevy  Â·  3Comments

gabrielpedepera picture gabrielpedepera  Â·  3Comments

MatthiasJ picture MatthiasJ  Â·  4Comments

nfischer picture nfischer  Â·  3Comments

jwhipp picture jwhipp  Â·  3Comments