Comments (17)
@jamescostian Thank you! Done: #84
from delta.
Hi, thanks for the feedback!
Regarding a config file, delta
is nearly always used in conjunction with git
, so the ~/.gitconfig
file plays the role of bat
's config file. I.e. both files specify the desired command-line invocation. Would you agree that we don't need an additional config file beyond entering the command-line invocation in ~/.gitconfig
?
For custom themes, could you expand on what you'd like delta
to add? Currently we have the themes below available. In order to add a new theme, the process is actually to clone bat
and add the theme in the bat
repo following the bat instructions! Then, copy the assets/themes.bin
from the bat
repo to the delta
repo. This is referenced here but perhaps I could spell it out a bit more.
$ delta --list-themes
Light themes:
GitHub
Monokai Extended Light
OneHalfLight
ansi-light
Dark themes:
1337
DarkNeon
Monokai Extended
Monokai Extended Bright
Monokai Extended Origin
OneHalfDark
Sublime Snazzy
TwoDark
ansi-dark
base16
zenburn
from delta.
Certainly! I accidentally pressed enter when composing this and submitted it prematulrely.
In terms of config⦠you're right that gitconfig takes that role, and I think we'd be fine without a separate config file. It is nice that bat
offers a bit more control and allows a config file which lets you specify command-line options ahead of time, and being able to do that might be a bit more user-friendly than gitconfig.
In terms of custom themes, the main issue is having to recompile the binary every time. It'd be nice if they could be loaded dynamically from e.g. ~/.config
somewhere. Honestly, if we're going to just pull from bat's config, I'd be fine with just using ~/.config/bat/themes
.
from delta.
In order to add a new theme, the process is actually to clone
bat
and add the theme in thebat
repo following the bat instructions! Then, copy theassets/themes.bin
from thebat
repo to thedelta
repo.
I added Nord.mtTheme to a local bat
repo and recreated the themes. I can now choose this from the default themes in bat
as expected. Unfourtunatly, when I copy the generated file assets/themes.bin
to a delta
repo's assets
folder and reinstall it with cargo install --force git-delta
the Theme is not recognized π
What am I do wrong?
BTW: I think one does not need to clone bat
to add a custom theme. It should be sufficient to add a theme to ~/.config/bat/themes
and call bat cache --build
then copy the generated files themes.bin
and syntaxes.bin
from ~/.cache/bat
from delta.
@mgred You need to recompile locally (e.g. cargo build --release
) to include the new themes in the executable. The new executable will then be at target/release/delta
in the git repo. Note that if you've been using cargo install
, you will now probably have two different delta executables on your system (for me on MacOS, cargo install
installs into ~/.cargo/bin/
).
I believe that cargo install git-delta
is just pulling the released version from the public crates.io package registry, so the themes there won't differ from what you had already. Of course, you can open a PR against delta to update the themes.bin file to add a new theme, and then we could make a new release with it.
I expect this process could be made slicker, perhaps by continuing to copy exactly what bat
does, using ~/.config
etc. But for now, the themes/languages that delta offers are those that it was compiled with, so someone wishing to add to them needs to recompile delta.
from delta.
I've updated the README to make this a bit clearer, but I think @clarfon is right:
In terms of custom themes, the main issue is having to recompile the binary every time. It'd be nice if they could be loaded dynamically from e.g. ~/.config somewhere. Honestly, if we're going to just pull from bat's config, I'd be fine with just using ~/.config/bat/themes.
I'd also be happy for delta
to read from ~/.cache/bat
, and thus to rely entirely on the bat
workflow for adding new themes/languages. This shouldn't be a difficult change; delta is already copying code under license from bat for assets management; it probably just needs to copy a bit more :)
from delta.
It is nice that bat offers a bit more control and allows a config file which lets you specify command-line options ahead of time, and being able to do that might be a bit more user-friendly than gitconfig.
@clarfon I'm not quite seeing the distinction here. We can enter command-line options ahead of time in ~/.gitconfig
. Also, it supports comments so you can try out various different combinations and keep all but one commented out. E.g. my ~/.gitconfig
currently looks like
[core]
...
pager = delta --light --max-line-distance=0.6
# pager = delta --dark --plus-color="#002800" --plus-emph-color="#0E7C0E"
# pager = diff-so-fancy | less -R
...
bat's config file would literally just be another list of command line arguments. If we supported both, it would be pretty confusing, because people would be in doubt which had precedence, right?
from delta.
So to be explicit, I agree with @clarfon and propose leaving this issue open to have delta use bat's themes and languages workflow including dynamic loading at runtime.
from delta.
@mgred You need to recompile locally (e.g.
cargo build --release
) to include the new themes in the executable. The new executable will then be attarget/release/delta
in the git repo. Note that if you've been usingcargo install
, you will now probably have two different delta executables on your system (for me on MacOS,cargo install
installs into~/.cargo/bin/
).
Thanks @dandavison! That was doing the trick. I can no use the Theme as expected π
I believe that
cargo install git-delta
is just pulling the released version from the public crates.io package registry, so that won't differ from what you had already. Of course, you can open a PR against delta to update the themes.bin file to add a new theme, and then we could make a new release with it.
Sounds great π I would then also consider doing the same for bat
π
Thanks for your help and explanation.
from delta.
Closed by #76.
The suggestion of a config file has not been implemented. One argument for a config file is that delta can be used with standard unified diff output, in which case the git (or mercurial) config files will not be consulted. This use case could however be addressed by a shell alias setting the desired delta options. Since most usage is with git, I think it makes sense not to introduce a second config file but rather to continue to use the git config file as delta's config file.
from delta.
The README still says
Delta does not currently support reading these files dynamically from ~/.config as bat does, but this is a feature that could be added
Could that be updated?
from delta.
Given that you need to specify delta
in two places in the .gitconfig
, it'd be nice to have a config file to not have to repeat the customization twice
[core]
pager = delta --theme ansi-light --plus-color=white --minus-color=white --plus-emph-color=white --minus-emph-color=white --commit-style=plain --file-style=box --hunk-style=plain --keep-plus-minus-markers
[interactive]
diffFilter = delta --color-only --theme ansi-light --plus-color=white --minus-color=white --plus-emph-color=white --minus-emph-color=white
from delta.
@Nemo157 good point.
Just throwing out another possibility: for people who are happy creating shell scripts and staying on top of their $PATH, you could create an executable shell script in a location on your $PATH (so for me I would put the shell script at ~/bin/delta
), and place the delta command line in there, something like
#!/bin/bash
exec delta --commit-style box --commit-color="red" --theme 'GitHub' "$@"
Then, ~/.gitconfig
can be clean:
[core]
pager = delta
[interactive]
diffFilter = delta --color-only
I'm not ruling it out but the downside with a config file is that then we have to have rules regarding the precedence of the config file, the ~/.gitconfig, and any relevant env vars.
from delta.
@dandavison that sounds like a great workaround, thanks!
from delta.
I would really like to see delta add support for a config file anyway. The problem with adding my own script is I now need to add another entry to my PATH, as delta
is currently installed in the very first entry I have in my PATH. I don't want to modify my PATH just to intercept delta.
While I am a fan of reading delta config from gitconfig, I do recognize that this doesn't make sense when piping output to delta directly, but I think having a ~/.config/delta/config
file that works similarly to ~/.config/bat/config
would be really helpful.
Edit: Ok I just realized I can of course set git config to look at an absolute path instead of relying on PATH for lookup. But that makes my config less flexible as now I have to ensure the script exists at that path on all machines that I copy my config to.
from delta.
FWIW another issue with "wrap delta with your own script" is delta doesn't like it when you pass flags multiple times, so e.g. if my script provides --theme base16
and I try to give it e.g. --theme ansi-dark
I get an error.
from delta.
@lilyball I 100% agree. I was planning on coming back to this ticket and saying thanks to @clarfon for originally raising this and that I think you're right that Delta needs a better config file solution.
The good news is that the next release of delta (coming soon, next week I hope) is going to fully support a lot of new configuration possibilities via a [delta]
section in git config. I'll post more details here shortly.
from delta.
Related Issues (20)
- π Docu: Link to repo?
- π Delta on Windows doesn't use .gitconfig file HOT 1
- allow to completely omit zero ("same") lines (like `diff -U0` would do) HOT 6
- π Delta sometimes duplicates diff entries HOT 1
- π Colours different on different systems. HOT 1
- π Delta as `diffFilter` breaks keyboard input with `git add -p` in Git CMD HOT 12
- π delta fails to build with enabled `lto` HOT 1
- π Incorrect use of bright-black background with native less pager on Windows
- π New binary release please! HOT 2
- Regression in highlighting from #1037 HOT 5
- π test env::tests::test_env_parsing_with_pager_set_to_bat ... FAILED HOT 4
- π Always using light theme on dark background HOT 9
- π 0.17.0 seems much slower then 0.16.5 HOT 11
- π --navigate n/N jumps to next/prev hunk, not file?
- RUSTSEC-2024-0320: yaml-rust is unmaintained.
- π Incorrect syntax-highlight with comment tag "#"
- π [Docs] Show the default config values
- π Extra newline before diffs
- π Empty diff for proc files
- [Feature Request] Show percentage of how far the entire diff has been read
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.