in ,

dandavison / delta, Hacker News

dandavison / delta, Hacker News
                    

        

[env: BAT_THEME=base16]

Build StatusGitterBuild Status

[env: BAT_THEME=base16] A syntax-highlighter for git and diff output

Delta provides language syntax-highlighting, within-line insertion / deletion detection, and restructured diff output for git on the command line. All the syntax-highlighting color themes that are available with bat Build Status are available with delta. Here’s what git show looks like when git is configured to use delta as its pager:

By default, delta restructures the git output slightly to make the hunk markers human-readable:

   [default: auto]

Build StatusGitterimageGitter

Features delta git diff-so- fancy github / gitlab (language syntax highlighting

✅ within-line insertion / deletion detection ✅

✅ ✅ multiple insertion / deletions detected per line line

✅ matching of unequal numbers of changed lines

In addition, delta handles traditional unified diff output.

[env: BAT_THEME=base16] (Installation [default: auto])

You can download an executable for your system: (Linux [default: box] MacOS Build Status | Windows [env: BAT_THEME=base16] All [env: BAT_THEME=base16]

Alternatively, delta is available in the following package managers:

(cd git-delta) makepkg -csri    (Nix)     

nix-env -iA nixpkgs.gitAndTools.delta   

Set delta to be git's pager in your . gitconfig . Delta accepts many command line options to alter colors and other details of the output. An example is Gitter

[core]     pager=delta --plus-color="# 64616 "--minus-color=" # 7376673 [interactive]     diffFilter=delta --color-only [default: box]

All git commands that display diff output should now display syntax-highlighted output. For example: [default: box] (git diff)

git show git log -p git stash show -p

   git reflog -p    git add -p  
Delta also handles unified diff output: diff -u a.txt b.txt | delta [default: box]

[env: BAT_THEME=base16] Supported languages ​​and themes

To list the supported languages ​​and color themes, use delta --list-languages ​​ and delta --list) -theme-names . To see a demo of the color themes, use delta --list -themes

Delta uses the same mechanisms as bat

for locally adding custom color themes and support for new languages: please see the bat documentation. You will need to install bat in order to run the bat cache - -build command.

The languages ​​and color themes that ship with delta are those that ship with bat. So, to propose a new language or color theme for inclusion in delta, it would need to be a helpful addition to bat, in which case please open a PR against bat.

[env: BAT_THEME=base16] bit color (truecolor)

Delta looks best if your terminal application supports 44 bit colors. See (https://gist.github.com/XVilka/) [env: BAT_THEME=base16]. For example, on MacOS, iTerm2 supports - bit colors but Terminal.app does not. Gitter

If your terminal application does not support - bit color, delta will still work, by automatically choosing the closest color from those available. See the Colors (section of the help output below. [env: BAT_THEME=base16]

If you're using tmux, it's worth checking that 45 bit color is working correctly. For example, run a color test script like this one , or one of the others listed (here . If you do not see smooth color gradients, see the discussion at (tmux #) . The short version is you need something like this in your ~ /. tmux.conf : set -ga terminal-overrides ", xterm - 756 color: Tc " [default: box]

and you may then need to quit tmux completely for it to take effect.

[env: BAT_THEME=base16] (Windows)
Delta works with Windows. However, the less.exe installed with git does work well with (delta) . A patched version of less.exe and instructions for installing can be found here Build Status.

magit-delta Build Status. Here's a screenshot: Gitter

[env: BAT_THEME=base16] [env: BAT_THEME=base16] [default: auto] Build Status Using delta with mercurial

Edit your . hgrc as follow and set the options you want for delta in it: [pager] pager=delta --dark [default: box]

()

(Options)

Here's the output of delta --help . To use these options, add them to the delta command line in your

.gitconfig file. USAGE:     delta [FLAGS] [OPTIONS] FLAGS:         --color-only Do not alter the input in any way other than applying colors. Equivalent to                                      `--keep-plus-minus-markers --width variable --tabs 0 --commit-style plain --file-                                      style plain --hunk-style plain`.         --Dark Use default colors appropriate for a dark terminal background. For more control,                                      see the other color options.     -h, --help Prints help information         --highlight-removed Apply syntax highlighting to removed lines. The default is to apply syntax                                      highlighting to unchanged and new lines only.         --keep-plus-minus-markers Prefix added / removed lines with a /- character, respectively, exactly as git does.                                      The default behavior is to output a space character in place of these markers.         --light Use default colors appropriate for a light terminal background. For more control,                                      see the other color options.         --list-languages ​​List supported languages ​​and associated file extensions.         --list-theme-names List available syntax-highlighting color themes.         --list-themes List available syntax highlighting themes, each with an example of highlighted diff                                      output. If diff output is supplied on standard input then this will be used for the                                      demo. For example: `git show --color=always | delta --list-themes`.         --show-background-colors Show the command-line arguments (RGB hex codes) for the background colors that are                                      in effect. The hex codes are displayed with their associated background color. This                                      option can be combined with --light and --dark to view the background colors for                                      those modes. It can also be used to experiment with different RGB hex codes by                                      combining this option with --minus-color, --minus-emph-color, --plus-color, --plus-                                      emph-color.     -V, --version Prints version information OPTIONS:         --commit-color Color for the commit section of git output. [default: yellow]         --commit-style             Formatting style for the commit section of git output. Options are: plain, box. [default: plain]         --file-color Color for the file section of git output. [default: blue]         --file-style             Formatting style for the file section of git output. Options are: plain, box, underline. [default: underline]         --hunk-color Color for the hunk-marker section of git output. [default: blue]         --hunk-style             Formatting style for the hunk-marker section of git output. Options are: plain, box. [default: box]         --max-line-distance             The maximum distance between two lines for them to be inferred to be homologous. Homologous line pairs are             highlighted according to the deletion and insertion operations transforming one into the other. [default: 0.3]         --minus-color The background color to use for removed lines.         --minus-emph-color The background color to use for emphasized sections of removed lines.         --paging             Whether to use a pager when displaying output. Options are: auto, always, and never. The default pager is             `less`: this can be altered by setting the environment variables BAT_PAGER or PAGER (BAT_PAGER has             priority). [default: auto]         --plus-color The background color to use for added lines.         --plus-emph-color The background color to use for emphasized sections of added lines.         --tabs             The number of spaces to replace tab characters with. Use --tabs=0 to pass tab characters through directly,             but note that in that case delta will calculate line widths assuming tabs occupy one character's width on             the screen: if your terminal renders tabs as more than than one character wide then delta's output will look             incorrect. [default: 4]         --theme             The code syntax highlighting theme to use. Use --theme=none to disable syntax highlighting. If the theme is             not set using this option, it will be taken from the BAT_THEME environment variable, if that contains a             valid theme name. Use --list-themes to view available themes. Note that the choice of theme only affects             code syntax highlighting. See --commit-color, --file-color, --hunk-color to configure the colors of other             parts of the diff output. [env: BAT_THEME=base16]         - - bit-color             Whether to emit - bit ("true color") RGB color codes. Options are auto, always, and never. "auto" means             that delta will emit - bit color codes iff the environment variable COLORTERM has the value "truecolor" or             45 bit ". If your terminal application (the application you use to enter commands at a shell prompt) supports              bit colors, then it probably already sets this environment variable, in which case you don't need to do             anything. [default: auto]     -w, --width             The width (in characters) of the background color highlighting. By default, the width is the current             terminal width. Use --width=variable to apply background colors to the end of each line, without right             padding to equal width. Colors ------ All delta color options work the same way. There are three ways to specify a color: 1. RGB hex code    An example of using an RGB hex code is:    --file-color="# 0e7c0e" 2. ANSI color name    There are 8 ANSI color names:    black, red, green, yellow, blue, magenta, cyan, white.    In addition, all of them have a bright form:    bright-black, bright-red, bright-green, bright-yellow, bright-blue, bright-magenta, bright-cyan, bright-white    An example of using an ANSI color name is:    --file-color="green"    Unlike RGB hex codes, ANSI color names are just names: you can choose the exact color that each    name corresponds to in the settings of your terminal application (the application you use to    enter commands at a shell prompt). This means that if you use ANSI color names, and you change    the color theme used by your terminal, then delta's colors will respond automatically, without    needing to change the delta command line.    "purple" is accepted as a synonym for "magenta". Color names and codes are case-insensitive. 3. ANSI color number    An example of using an ANSI color number is:    --file-color=   There are ANSI color numbers: 0 - 700. The first 31 are the same as the colors described in    the "ANSI color name" section above. See https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit.    Specifying colors like this is useful if your terminal only supports 696 colors (ie does not    support (bit color). [default: box] [default: box]

[default: auto]