Comments (13)
Here's something that does work, at the cost of slightly uglier output:
git log -p | delta --file-style plain | less -R --pattern '^(Date: |added: |deleted: |renamed: |diff --git)'
That's not as bad as I thought it would be, to be honest 😄
So -- what do you think? Is it worth adding an option for delta to emit a searchable anchor along with the modified file name? (And if so would you like to work on it? :) ) In general I would say that the part of delta involving the various options for changing the way different sections of the diff output are styled, is probably an area that could benefit from some more attention.
I think it's useful or it's just my muscle memory, I also don't mind working on it but I have zero Rust experience so I will need lots of help 😉
We could add back the word "modified" and be done with it, but I wonder whether more in keeping with delta's aims would be to use a set of single-character symbols, instead of the full words, e.g.
→ added ← removed Δ modified ♻ renamed
I honestly think bringing back "modified" is the best option, adding icons should be optional IMO.
from delta.
We could add back the word "modified" and be done with it, but I wonder whether more in keeping with delta's aims would be to use a set of single-character symbols, instead of the full words, e.g.
→ added
← removed
Δ modified
♻ renamed
from delta.
Hi everyone, this should be addressed now in the master
branch. If you're able to try it out, that would be great (instructions for building delta).
Here's what I've done. Basically there are now two ways to activate diff navigation in delta:
-
Use new option
delta --navigate
. This will set theless --pattern
regexp automatically, according to the values of the new options described below. -
Use
delta --file-modified-label="XXXX"
and set theless --pattern
regexp yourself (e.g. using one of the environment variablesLESS
,BAT_PAGER
,PAGER
)
New option | Default value |
---|---|
--file-modified-label |
"" |
--file-removed-label |
"removed:" |
--file-added-label |
"added:" |
--file-renamed-label |
"renamed:" |
I know that some people suggested prefixing every file path with modified:
by default but I couldn't bring myself to do that :) One of the aims of Delta is visually clean output by default, and 95% of the time one is looking at a modified file, so that 9-character English word felt noisy to me.
By default, delta --navigate
uses the unicode character Δ
, so here's what it looks like on my current white background.1
But that's just the default, you can do
delta --navigate --file-modified-label="modified:"
In general it shouldn't be necessary to pipe delta
into less
: delta
starts its own less
process automatically. (This is what bat
does also, but with diff-so-fancy
you have to pipe it explicitly to less
.)
Feedback and testing on master
very welcome!
1 Just to be totally explicit for anyone reading this, Δ
is used in math to mean "a change to a quantity" so the idea is that one thinks of it here as meaning "change to a file".
from delta.
Hi @dsifford, soon! I'm working on it. There have been a huge number of changes related to how we configure stylable elements (see #205) and in master we can now use ~/.gitconfig
to configure delta. So no more features to be added before next release! But I need to do a bit more work and add tests to make sure all this is solid.
from delta.
--navigate
is available in delta v0.2.0 which was released today.
from delta.
Cool, that's a neat trick! So, here's what's going on:
git show
displays the commit metadata (which includesDate:
), so it's working for the Date anchors, at least. (git log -p
also works in that sense)git diff
does not show commit metadata, so the only thinggit diff
will anchor on isadded|deleted|modified|renamed
- The thing is,
delta
does not currently print out the word "modified". I made that decision because one of my aims fordelta
was to be a "cleaned up" / "minimal" diff view, and in practice, in a git repo, one is nearly always looking at modified files, so it didn't seem necessary to print the word "modified". - So
git diff
will work for you if you have added/deleted/renamed files, but if there are none of those it fails with "pattern not found".
OK, so how can we make this work better?
One idea is to match the horizontal line separator delta uses at each new file. E.g. something like this:
'^(Date|added|deleted|──────────────────────────────────────────────────────────────────────────────|renamed)'
Unfortunately, every time it jumps to the match, it leaves the actual file name off screen by one line, which isn't helpful. If we could use a regexp that matches two lines it could work, but it looks like that that's just not going to be possible.
Here's something that does work, at the cost of slightly uglier output:
git log -p | delta --file-style plain | less -R --pattern '^(Date: |added: |deleted: |renamed: |diff --git)'
So -- what do you think? Is it worth adding an option for delta to emit a searchable anchor along with the modified file name? (And if so would you like to work on it? :) ) In general I would say that the part of delta involving the various options for changing the way different sections of the diff output are styled, is probably an area that could benefit from some more attention.
from delta.
I think it's been too long without a solution for this (#199 calls for this feature also cc @driesg). One good thing is that delta starts its own less
process, so it can potentially set the regular expression itself.
from delta.
I honestly think bringing back "modified" is the best option, adding icons should be optional IMO.
I tend to agree with this, text is usually more clear than icons.
In general I would say that the part of delta involving the various options for changing the way different sections of the diff output are styled, is probably an area that could benefit from some more attention.
@dandavison where would you start?
from delta.
dotfiles log -p | delta | less -R -j2 --pattern '^(Date|added|deleted|──────────────────────────────────────────────────────────────────────────────|renamed)'
from delta.
@dandavison Any idea when the next release is going to be slated? Would love to not have to build directly from source to use this. 🙏
from delta.
Thanks @dandavison! I got back from leave and have a few things to catch up on. Once that's done, I can have a go at building from source and report any findings
from delta.
Works like a charm. Thanks @dandavison 👍
from delta.
The latest release of delta allows navigate
to be activated via an environment variable, e.g.:
DELTA_NAVIGATE=1 git diff
This is motivated by the fact that leaving navigate
active all the time is problematic; please see the README section https://github.com/dandavison/delta#navigation-keybindings-for-large-diffs
from delta.
Related Issues (20)
- Navigate keybinds only go between hunks, not files
- update intsructions for tmux color issues
- 🐛 Online user manual website not working HOT 4
- 🐛 When piping --help, the output should not contain escape chars
- 🐛 `--color-only` doesn't produce any colour HOT 2
- 🚀 diff chinese words better HOT 2
- 🐛 Highlighting of capitalisation changes does not match `diff-so-fancy` when using `delta diff-so-fancy` HOT 1
- 🐛 Emacs lisp incorrect highlighting HOT 1
- 🚀 hjkl key bindings as arrow keys HOT 2
- 🚀 Enable using delta in git when output is piped (`git diff | cat`) HOT 3
- 🚀 use diff-compatible exit statuses that differ between difference-found and error HOT 8
- 🚀 Please add support for cargo-binstall HOT 1
- 🐛 wrong highlight with `rg --json | delta` when tabs are involved HOT 2
- 🚀 `ws-error-highlight`
- 🐛 Homebrew cannot install from HEAD HOT 2
- 🐛 delta fails to run (in some cases) when `git` is not installed
- 🐛 White space before 2nd, 3rd `k` shouldn't be in highlighted scope
- 🐛 delta not respecting LESS -F environment variable (--quit-if-one-screen) HOT 2
- 🐛 Syntax highlighting fails when the visible snippet includes a multiline comment HOT 2
- 🐛 error: unexpected argument '--generate-completion' found
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from delta.