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

Change background colour based on Git status #163

Closed
hybridvision opened this issue Jun 7, 2021 · 4 comments
Closed

Change background colour based on Git status #163

hybridvision opened this issue Jun 7, 2021 · 4 comments
Labels
🌊 enhancement New feature or request
Milestone

Comments

@hybridvision
Copy link

Is your feature request related to a problem? Please describe

In the Rainbow prompt style it would be really nice if the background colour could also be changed depending on the Git status (like in bobthefish)

Describe the solution you'd like

I've already experimented with this by editing _tide_item_git.fish but rather than submitting a pull request, I thought this was better as a feature request because there might be some debate about the best way to handle it. For example, there can only be one background colour at a time so when there are multiple different statuses, there would need to be a priority for which colour was used.

I was thinking of something like this, added just before the information is printed:

if set -q conflicted
    set -g tide_git_bg_color $tide_git_conflicted_bg_color
else if set -q dirty
    set -g tide_git_bg_color $tide_git_dirty_bg_color
else if set -q staged
    set -g tide_git_bg_color $tide_git_staged_bg_color
else if set -q stash
    set -g tide_git_bg_color $tide_git_stash_bg_color
else if set -q untracked
    set -g tide_git_bg_color $tide_git_untracked_bg_color
end

This is just a quick attempt - the extra variables would need to be defined in the presets and maybe there's a more elegant way of doing this. I welcome any feedback!

Additional context

A quick example of how it might look...

image

What do you think?

@hybridvision hybridvision added the 🌊 enhancement New feature or request label Jun 7, 2021
@IlanCosman
Copy link
Owner

IlanCosman commented Jun 7, 2021

I'm certainly open to the idea, but I don't want to have a separate color for every single state. That seems kind of "mentally busy" to me, in that people wouldn't remember which color corresponds to which, and what the chain of priority is.

Bobthefish only has colors for normal and dirty right? I'd suggest we do similarly. One for normal, one for dirty, and one for conflicted/ongoing operation. Thoughts?

@hybridvision
Copy link
Author

Hi @IlanCosman,

Thanks for your reply! I totally agree about having too many colours and it being too mentally busy. Personally, I only really care if it is clean / dirty / conflicted but I wasn't sure if others had more sophisticated needs.

I think 3 different colours would be sufficient because there are always the other indicators that give more fine-grained detail about the status. In my opinion, conflicted deserves its own unique colour so I would suggest the following:

  1. Conflicted (red)
  2. Dirty / Untracked / Ongoing operations (yellow)
  3. Normal / Clean (green)

One thing I'm not totally sure about is if untracked files should trigger the dirty colour or not... My logic is that untracked files are a signal that requires some attention so that they can either be added or ignored. Does that make sense?

@IlanCosman
Copy link
Owner

Sorry for the delay 😅 I hadn't realized that P10k does this, but apparently it does, so perhaps we should take what it does under consideration:

P10k:
Untracked, Stashed, commits ahead/behind = Green background
Dirty, Staged = Yellow background
Operations, Conflicted = red text on green/yellow background.

Here's what it looks like in action:

p10k-git

The red on green clashes really badly, and using a red foreground to convey information when we use background for everything else seems a bit weird.

I agree with your assessment of untracked files, though both P10k and Bobthefish disagree.

So here's my proposal (which is quite similar to yours):

File types/states color meaning
Stashed, commits ahead/behind green background nothing to do, repo is in a stable state
Dirty, Staged, Untracked yellow background repo has common things that need to be dealt with, but not immediately
Operations, conflicted red background repo has less common things that need to be dealt with immediately

@IlanCosman IlanCosman added this to the v5.0.0 milestone Jun 26, 2021
@hybridvision
Copy link
Author

Your proposal makes perfect sense to me and I'd be happy if it worked like that 👍

I agree about not using different foreground colours to convey meaning when background colours are in use. I think the only time the text colour should change from the default is to provide better contrast against the background colour, if necessary.

By the way, it's a bit of a tangent but have you seen https://github.com/jandedobbeleer/oh-my-posh? I came across it recently and there are some potentially interesting ideas in the way it is constructed - for example, the handling of themes via JSON. I thought you might be interested if you're not already aware of it.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🌊 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants