Giter Club home page Giter Club logo

git-rainbow's Introduction

Expanded color hints for your git prompt.

__git_color returns an escape sequence representing a color hint. Hints indicate dirty state, stashes, and untracked files, and can replace the GIT_PS1_SHOW* variables for all of these.

Hints are: (assuming standard xterm color palette)
Green: branch is up to date
Red: unstaged changes present
Yellow: staged changes present
Blue: untracked files present
Purple: untracked files + unstaged changes
Cyan: untracked files + staged changes
Underline: stashes present

__git_color is meant to be used with __git_ps1, and can be placed in the formatting argument, or elsewhere. Example:

PS1='[!]\u@\h:\w$(__git_ps1 " ([$(__git_color -y)]%s[\033[0m])")$ '

Two things to note:

  1. Prompt strings expect nonprinting characters to be bracketed with [ ] (or %{ %} if you're using zsh). __git_color does not return these brackets. This allows you to use __git_color outside the prompt string.
  2. Remember to reset the colors using \033[0m before the end of your string.

Usage: __git_color [STAGE_BEHAVIOR]

STAGE_BEHAVIOR controls the hint when both staged and unstaged changes are present. By default, unstaged changes take precedence, so the hint is red (purple if there are also untracked files). Options are:
Red - red/purple hints
Yellow - yellow/cyan hints (staged changes take precedence)
Both - yellow/cyan hints with red background

The default behavior can be changed by setting the GIT_COLOR_STAGEBEHAVIOR variable. Supplying an argument will always override this. At present, the argument is case-insensitive, can have any number of leading dashes, and only looks at the first letter (so -y, --yellow, YELLOW, and -------Yentl will all be interpreted as Yellow).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.