Giter Site home page Giter Site logo

dandavison / delta Goto Github PK

View Code? Open in Web Editor NEW
20.7K 79.0 344.0 10.01 MB

A syntax-highlighting pager for git, diff, and grep output

Home Page: https://dandavison.github.io/delta/

License: MIT License

Rust 94.99% Shell 4.41% Makefile 0.46% Ruby 0.10% Dockerfile 0.03% Python 0.01%
git diff pager rust delta git-delta color-themes syntax-highlighter

delta's Introduction

image

CI Coverage Status Gitter

Get Started

Install it (the package is called "git-delta" in most package managers, but the executable is just delta) and add this to your ~/.gitconfig:

[core]
    pager = delta

[interactive]
    diffFilter = delta --color-only

[delta]
    navigate = true    # use n and N to move between diff sections

    # delta detects terminal colors automatically; set one of these to disable auto-detection
    # dark = true
    # light = true

[merge]
    conflictstyle = diff3

[diff]
    colorMoved = default

Delta has many features and is very customizable; please see the user manual.

Features

  • Language syntax highlighting with the same syntax-highlighting themes as bat
  • Word-level diff highlighting using a Levenshtein edit inference algorithm
  • Side-by-side view with line-wrapping
  • Line numbering
  • n and N keybindings to move between files in large diffs, and between diffs in log -p views (--navigate)
  • Improved merge conflict display
  • Improved git blame display (syntax highlighting; --hyperlinks formats commits as links to hosting provider etc. Supported hosting providers are: GitHub, GitLab, SourceHut, Codeberg)
  • Syntax-highlights grep output from rg, git grep, grep, etc
  • Support for Git's --color-moved feature.
  • Code can be copied directly from the diff (-/+ markers are removed by default).
  • diff-highlight and diff-so-fancy emulation modes
  • Commit hashes can be formatted as terminal hyperlinks to the hosting provider page (--hyperlinks). File paths can also be formatted as hyperlinks for opening in your OS.
  • Stylable box/line decorations to draw attention to commit, file and hunk header sections.
  • Style strings (foreground color, background color, font attributes) are supported for >20 stylable elements, using the same color/style language as git
  • Handles traditional unified diff output in addition to git output
  • Automatic detection of light/dark terminal background

A syntax-highlighting pager for git, diff, and grep output

Code evolves, and we all spend time studying diffs. Delta aims to make this both efficient and enjoyable: it allows you to make extensive changes to the layout and styling of diffs, as well as allowing you to stay arbitrarily close to the default git/diff output.

image
delta with line-numbers activated
image
delta with side-by-side and line-numbers activated

Here's what git show can look like with git configured to use delta:


image image
"Dracula" theme "GitHub" theme


Syntax-highlighting themes

All the syntax-highlighting color themes that are available with bat are available with delta:


image image
delta --show-syntax-themes --dark delta --show-syntax-themes --light

Side-by-side view

[User manual]

[delta]
    side-by-side = true

By default, side-by-side view has line-numbers activated, and has syntax highlighting in both the left and right panels: [config]

image

Side-by-side view wraps long lines automatically:

image

Line numbers

[User manual]

[delta]
    line-numbers = true
image

Merge conflicts

[User manual]

image

Git blame

[User manual]

image

Ripgrep, git grep

[User manual]

image

Installation and usage

Please see the user manual and delta --help.

delta's People

Contributors

2kabhishek avatar aironskin avatar ath3 avatar bash avatar chtenb avatar clnoll avatar dandavison avatar dependabot-preview[bot] avatar dependabot[bot] avatar dotdash avatar est31 avatar fdav10 avatar guillaumegomez avatar hakamadare avatar imbrish avatar kr1ss-xd avatar m-lima avatar marcoieni avatar mliszcz avatar navarroaxel avatar nickelc avatar p00f avatar phillipwood avatar rouge8 avatar sitiom avatar th1000s avatar waldyrious avatar wayned avatar wescande avatar yoichi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

delta's Issues

troubleshooting: base16 theme

It seems that base16 support for delta may be broken atm.

Screenshot from 2019-11-12 11-18-20

Here is bat's output when previewing the base16 theme

Screenshot from 2019-11-12 11-26-20

the color gradient test works and shows that my terminal supports 24 bit colors.

Unusual context box

The context box here is not sized correctly. It's also an odd attribution, but maybe that's git and not delta.

image

To repro:

git clone clone https://github.com/lzybkr/less
cd less
git show 163de2d

Checksum missmatch for 0.0.15 on MacOS

$ brew install dandavison/delta/git-delta
==> Installing git-delta from dandavison/delta
==> Downloading https://github.com/dandavison/delta/releases/download/0.0.15/delta-0.0.15-x86_64-apple-darwin.tar.gz
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/193526915/e4129e00-160e-11ea-97ce-b
######################################################################## 100.0%
Error: An exception occurred within a child process:
ChecksumMismatchError: SHA256 mismatch
Expected: a6df3b6d3a3698997dc84ddfe8d8880493524549138b18b9c9a48aa43c5b716f
Actual: d99153513940b2ce599a7913a8682403e507e2bf254abd50da560aae02f5329d

Terminal size is off by one on Linux

It appears, the detected terminal size is one character too wide:
image

I tried in Konsole-19.08.2, xterm-337, tmux-2.9a. I have not noticed any issues in other terminal apps such as tig.

I've tried on the latest release - 0.0.14.

Error: thread 'main' panicked at 'called `Option::unwrap()` on a `None` value'

I encounterd the following Error using git diff:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

The full output looks like:
Screenshot 2019-10-16 at 11 58 52

The shown diff ist wrong, the actual is:
Screenshot 2019-10-16 at 11 59 13

When I switch branch with different files changed and e.g. call git diff origin/master everyting works as expected.

BTW: I built delta myself with cargo build --release

--commit-style box and/or --file-style box causes write_boxed_with_line to panic

With a narrow terminal (<= 48 chars), --commit-style box results in:

> git show
thread 'main' panicked at 'attempt to subtract with overflow', src/draw.rs:39:35
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

Because line_width <= box_width, so line_width - box_width - 1 would be negative.

Or a more practical scenario: even with a reasonably wide terminal, very long filenames cause the same issue under --file-style box.

Display of merge conflict output

Investigate use of background color highlighting (and syntax highlighting) to produce a helpful and pleasing display of git merge conflict output.

Moving around diffs

I'd like to do something like this diff-so-fancy moving around diff

I tried this, but it only worked with git show but not git diff

pager = delta --dark --hunk-style plain --theme OneHalfDark | less --pattern '^(Date|added|deleted|modified|renamed): '

Support mouse scroll

In the default git pager (less on my system) I can use the mouse scroll wheel to scroll through the pager output. When delta is used, the mouse scroll does not work, and I'm forced to use the navigation shortcuts. It would be really nice to be able to scroll with the mouse wheel.

System: Linux pop-os 5.3.0-22-generic #24+system76~1573659475~19.10~26b2022-Ubuntu SMP Wed Nov 13 20:0 x86_64 x86_64 x86_64 GNU/Linux

Solarized not supported

I'm a little confused as, although I can see a PR to add solarized and this code here seems to list Solarized (light) as a theme, I can't see solarized themes (light or dark) in delta --list-themes or get it working with this in my git config:

  pager = delta --dark --theme='Solarized (light)'

image

dark theme doesn't match repo and is hard to read

Hello, I'm unable to replicate the dark theme on the README here. This is the diff for git diff 13e39b1~10. This is not necessarily an issue with delta, and could very well be my terminal setup in general. How can I go about debugging what the reason is for this? The annoying thing is this is a similar output even when I use a different theme.

Screenshot from 2020-01-07 03-02-00

Added first and last line of hunk is not highlighted

In my test case I add lines x and y before and after a hunk a b c:

❯ cat a
a
b
c
❯ cat b
x
  a
  b
  c
y

delta detects that the spaces in front of a b c changed and highlights them, but does not highlight the first and last line of the hunk (x and y):

❯ diff -u a b | delta
[...junk...]
1
 a                                                                                                                                                                                                                                                                                                                                                                                                                                       
 b                                                                                                                                                                                                                                                                                                                                                                                                                                       
 c                                                                                                                                                                                                                                                                                                                                                                                                                                       
 x                                                                                                                                                                                                                                                                                                                                                                                                                                       
   a                                                                                                                                                                                                                                                                                                                                                                                                                                     
   b                                                                                                                                                                                                                                                                                                                                                                                                                                     
   c                                                                                                                                                                                                                                                                                                                                                                                                                                     
 y

Using delta 0.0.14.

Fixed / pinned file name / function / chunk header

It would be awesome if the file name / function / chunk header, that delta displays before each file / function / chunk, would be fixed / pinned to the top of the screen and just the file content would scroll. When scrolling into the next file, its file name header would scroll up until it takes the place of the previous file's header, at which point it would be fixed / pinned to the top of the screen, and so on. That way it would always be obvious which file, and inside that file which function, I am looking at. I think it could simplify larger reviews quite a bit.

There is a sister-feature-request for bat: sharkdp/bat#754 and nushell: nushell/nushell#389
Maybe you can find a solution for this together with the bat and the nushell devs?

Windows support

Is Windows support planned?

delta builds successfully if you remove the dependency on termios from Cargo.toml.

Trying it out though it seems there are a couple issues demonstrated in the screenshot below (which is captured from my 1 line change to get delta to build):

image

Note first line in the box around the context is off by 1.

But more worrisome - the actual diff in Cargo.toml isn't highlighted at all like the default pager would:

image

Full-width bars are one character too long

Using iterm2 Build 3.3.3beta2 on Mac 10.13.6. The bars that are meant to span the terminal are one character too long, and so wrap. It happens with --compare-themes as well as when being used as a pager:
image
Is the blank at the start of the line supposed to be there?

Support diff -u ... | delta

It would be nice if diff -u ... | delta was supported. Currently delta does not appear to parse the header correctly and instead passes on some garbage:

❯ diff -u a b | delta
diff -u a/file b/file
--- a/file      2019-11-12 19:33:40.199834121 +0100

file    2019-11-12
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
+++ b/file      2019-11-12 19:33:54.767769647 +0100

1
 a                                                                                                                                                                                                                                                                                                                                                                                                                                       
 b                                                                                                                                                                                                                                                                                                                                                                                                                                       
 c                                                                                                                                                                                                                                                                                                                                                                                                                                       
 x                                                                                                                                                                                                                                                                                                                                                                                                                                       
   a                                                                                                                                                                                                                                                                                                                                                                                                                                     
   b                                                                                                                                                                                                                                                                                                                                                                                                                                     
   c                                                                                                                                                                                                                                                                                                                                                                                                                                     
 y                                                                                                                                                                                                                                                                                                                                                                                                                                       
 iff -u a/file2 b/file2                                                                                                                                                                                                                                                                                                                                                                                                                  
--- a/file2     2019-11-12 19:40:49.344885714 +0100

file2   2019-11-12
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
+++ b/file2     2019-11-12 19:40:54.800860547 +0100

1 
 1                                                                                                                                                                                                                                                                                                                                                                                                                                       
 2   

Note how the diff command for file2 even lost its first character. (It actually displays like that and is not a copy & paste mistake by me.)

Using delta version 0.0.14.

Add option to set the width of a tab character

Delta currently cannot calculate the correct line width when there are tabs present because it doesn't know how much width the tab takes up when it is rendered.

Originally posted by @dandavison in #14 (comment)

This can be resolved by adding a flag which sets the display width of a tab character, defaulting to something sensible (2, 4, or 8).

Green highlight is too bright for comments

The inserted word is basically invisible:
image
On regular code it's fine but could still be less bright:
image

Themes I tried: default, OneHalfDark. Terminal: alacritty. Alacritty theme: base16-ocean.

The project name makes this very difficult to find via search

Since deltas have meaning in a git context, searching for this project with keywords like github, git, delta, and download makes this project almost impossible to find. I had to give up and ask someone to link me to it. It would be nice to make this more discoverable.

FYI there is a (seemingly unmaintained) ruby gem named git-delta that I found, but I still couldn't Google my way to this repo.

providing theme via git config doesn't seem to work

Using:

  • delta-0.0.15-x86_64-pc-windows-msvc, also built and tested against latest master (9f258c1)
  • git version 2.24.1.windows.2 ("Git for Windows" builds)
  • less: lzybkr/less@163de2d

Oddities:

  • renamed delta.exe to git-delta.exe, both exhibit this issue
  • screencast shows the problem in the new Microsoft Terminal, but this issues happens in the stock console as well
  • The problem is the same regardless of the shell (tried with cmd.exe and pwsh.exe)

Screencast of the problem (provides a bit more context than this text alone):
https://www.youtube.com/watch?v=JZiZx-aR168

When I pipe from git to delta via git show | delta --dark or git show | delta --dark --theme='sometheme', everything seems to work fine.

However, when configuring git's pager to use delta, Delta does not seem to be using its default theme, and it is also not using the requested theme (if provided).
pager = delta --dark
pager = delta --dark --theme='Monokai Extended Origin'

Broken on macOS Catalina?

Tested (installed from homebrew) with a repo with just a README.md, doesn't show almost anything for me, I guess it silently segfaults when invoked via pager, see last screenshot (same error with or without theme).

OS: macOS Catalina w/ zsh as shell
Terminal: iTerm 3.3.6 (last stable)
git: 2.23.0 (last one on homebrew)
rustc 1.38.0

Normal git diff:
Screenshot 2019-10-14 at 11 34 55

Git Delta:
Screenshot 2019-10-14 at 11 35 18

Git Delta via pipe:
Screenshot 2019-10-14 at 11 41 42

Background color issues

image

Alacritty 0.4.0, delta 0.0.15

All light themes are broken.
Somehow --minus-color=xx does not set to xx, but adds xx.
--minus-color="#000000" shows minus diffs with no color.

🐛Handle diff.submodule log

It appears that delta has some trouble finding the end of a hunk:

--- a   2019-11-27 12:06:18.472973416 +0100
+++ b   2019-11-27 12:06:23.992967043 +0100
@@ -1,7 +1,7 @@
 x
 y
 z
-a
+b
 z
 y
 x
Submodule x/y/z contains untracked content

Is displayed (roughly) as:

a
---------------------------------------
-----|
 ... |
-----|
1
 x
 y
 z
-a
+b
 z
 y
 x
 ubmodule x/y/z contains untracked content

Note how "Submodule"'s first character gets removed by delta.

Using delta 0.0.14.

Install problem on Ubuntu 16.04

When I want to install on Ubuntu 16.04, I get the following error.
$ brew tap dandavison/delta https://github.com/dandavison/delta
...
$ brew install dandavison/delta/git-delta

Error: No available formula with the name "dandavison/delta/git-delta"
==> Searching for a previously deleted formula (in the last month)...
Warning: dandavison/delta is shallow clone. To get complete history run:
git -C "$(brew --repo dandavison/delta)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.

I'm new to brew so please excuse me if I've missed a simple thing. I can use brew install git-delta and it works fine.

Also:
$ brew --repo dandavison/delta /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/dandavison/homebrew-delta
and it's HEAD is 0052bd7

ctrl+c out of compare-themes not handled gracefully

I see this on both Windows and Linux. Sorry if this report is a big vague.

If I try --compare-themes and hit ctrl+c, sometimes it seems like delta tries to show another theme, or maybe just a couple lines, it's hard to tell what exactly is happening.

Once I saw this panic (on Windows):

Error: Os { code: 232, kind: BrokenPipe, message: "The pipe is being closed." }

but I haven't reproduced that. I do see some zombie less processes that I can't kill - again on Windows.

Support `git add -p` on Windows

If you try setting interactive.diffFilter to delta, you'll get an error:

fatal: mismatched output from interactive.diffFilter
hint: Your filter must maintain a one-to-one correspondence
hint: between its input and output lines.

If I add --file-style plain --hunk-style plain then git add -p "works", but there is no coloring at all.

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.