Giter VIP home page Giter VIP logo

lp-gitcrux's Introduction

GitCrux — A Liquid Prompt Theme

GitCrux is a theme for Liquid Prompt, showing visual hints inspired from GitCrux.

The objective of GitCrux is to help you finding which Git command to use, given the current state of your Git repository. Hints are given in a visual way, helping the user to understand what commands will change.

It targets users who are starting out with Git and struggle to rembemer the classical Git workflow.

Example:

Design

The first line of the prompt is the classical theme right from Liquid Prompt, only without the VCS information.

The second line shows the five main states tracked by Git:

  • the remote repository (with the number of remote commits behind),
  • the local repository (showed by its name),
  • the staged changes (showing either a wall clock, or the number of altered lines),
  • the branch (and the number of commits ahead),
  • the stash.

All lines after show colored arrow, figuring what states the denoted command will change. The color of the arrow figures the urgency to issue that command.

For instance, if there is only a few lines changed, the "add" arrow is shown in a light color, if there is several modified lines, the arrow will be colored more strongly, and if there is too much editions, the arrow will be heavily colored.

The prompt comes with the gitcrux command, that displays a diagram showing all the supported commands:

Setup

To actually use the GitCrux theme, you need to add a few configuration commands to the script that loads Liquid Prompt. For example:

# Load Liquid Prompt.
source ~/liquidprompt/liquidprompt
# Load the theme.
source ~/lp-gitcrux/gitcrux.theme && lp_theme gitcrux

By default, GitCrux needs a Nerd-font to display the arrows correctly. See the Nerd-fonts Fonts installation docs for help on installing this kind of fonts. If you do not have a Nerd-font, you may configure GITCRUX_ARROW_RIGHT and GITCRUX_ARROW_RIGHT to draw different arrow styles (see below).

Configuration

Liquid Prompt Configuration

The GitCrux theme honors all Liquid Prompt configuration options.

However, the command hints only targets Git (so far), even if they are showed for any supported VCS repository.

Theme configuration

Arrows

GITCRUX_ARROW_RIGHT array = ( "" "" )

Symbols used to draw arrow heads and tails.

GITCRUX_ARROW_LEFT array = ( "" "" )

Symbols used to draw arrow heads and tails.

GITCRUX_MIN_COL_WIDTH integer = 8

Minimum width of each of the Git state columns.

GITCRUX_COL_DYNAMIC boolean = 1

Automatically increase each columns width if at least one of the column text is larger than GITCRUX_MIN_COL_WIDTH.

GITCRUX_SHOW_EXPLANATION boolean = 1

Show a sentence explaining why the hint is shown.

Colors

GITCRUX_COLOR_WEAK string = "0 195 0"

Color of arrows if the related sensor is below "normal".

GITCRUX_COLOR_NORMAL string = "0 39 1"

Color of arrows if the related sensor is above "normal" and below "strong".

GITCRUX_COLOR_STRONG string = "0 220 1"

Color of arrows if the related sensor is above "strong".

GITCRUX_COLOR_MSG string = "0 244 0"

Color of error messages.

GITCRUX_COLOR_EXPLANATION string = "28 -1 0"

Color of explanation messages.

Thresholds.

GITCRUX_THRESH_BEHIND_NORMAL integer = 2

How many commits behind remote needs a "normal" alert.

GITCRUX_THRESH_BEHIND_STRONG integer = 5

How many commits behind remote needs a "strong" alert.

GITCRUX_THRESH_AHEAD_NORMAL integer = 2

How many commits ahead of remote needs a "normal" alert.

GITCRUX_THRESH_AHEAD_STRONG integer = 5

How many commits ahead remote needs a "strong" alert.

GITCRUX_THRESH_LINES_NORMAL integer = 100

How many modified lines needs a "normal" alert.

GITCRUX_THRESH_LINES_STRONG integer = 500

How many modified lines needs a "strong" alert.

GITCRUX_THRESH_ADD_NORMAL integer = 100

How many added files needs a "normal" alert.

GITCRUX_THRESH_ADD_STRONG integer = 500

How many added files needs a "strong" alert.

GITCRUX_THRESH_STASH_NORMAL integer = 1

How many stashed commits needs a "normal" alert.

GITCRUX_THRESH_STASH_STRONG integer = 5

How many stashed commits needs a "strong" alert.

lp-gitcrux's People

Contributors

nojhan avatar

Stargazers

 avatar

Watchers

 avatar  avatar

lp-gitcrux's Issues

Theme does not work on zsh

When trying to use the theme on zsh, we obtain multiple errors everytime it tries to display an arrow.

lp_terminal_format:11: bad math expression: operator expected at `195 0'
lp_terminal_format:13: bad math expression: operator expected at `195 0'
lp_terminal_format:15: bad math expression: operator expected at `195 0'
lp_terminal_format:17: bad math expression: operator expected at `195 0'

Apparently this might be related to the way zsh "expands" strings when given as arguments to a new function. For instance here:

lp_terminal_format ${color}

In Bash this is equivalent to lp_terminal_format 0 195 0 while in zsh it is lp_terminal_format "0 195 0". The second version both fails in bash and zsh if you try to type it in the command line, because lp_terminal_format expects 3 arguments.

One way to fix that in zsh is to use the z modifier like this: lp_terminal_format ${(z)color}. Unfortunately this is not compatible with bash, meaning we will have to test the environment everytime using _LP_SHELL_zshand _lp_SHELL_bash, making the code way more cumbersome.

There might be a better way to fix that that I’m not aware of.

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.