-
Notifications
You must be signed in to change notification settings - Fork 406
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
🚀 automatic side-by-side based on column width? #359
Comments
Or instead of using an env variable it could be specified in the gitconfig for the delta options. ex: |
Yes, my thinking was something like a If there is interest in principle, I'd also be happy to attempt to provide a PR for this feature. |
Hi @aschmolck @dmaahs2017, thanks! I agree that a It's not at all ideal, but what I currently do is something like
(as is in the README). Also your idea of an auto-side-by-side mode sounds interesting; I hadn't thought of that. Would the ideal be to re-use the same option, rather than to introduce another one? I.e.
@aschmolck great! I'll be happy to discuss designs and review code. |
@dandavison Yeah I think reusing this option would be the best UX. Where 120 could be any positive integer |
I think this is a good and useful idea!
This is just my opinion, but wouldn't the below example be confusing?
Would Putting P.S. |
It's a hard decision and maybe we can't revert this latter... but I like
instead of an extra configuration variable. But I think in the future someone will request a flag to turn off the side-by-side automatically if the compared file has a line longer than the half of the terminal, etc. |
@navarroaxel maybe overkill, but one option to future-proof (and self-document) it more would just be to make it more descriptive, e.g:
That's more verbose, but presumably that's not really an issue for a gitconfig line. It's a tad more annoying to parse, but again not that much. |
One thing we should bear in mind is that if we switch |
@dandavison If you dislike introducing new flags, think just extending the meaning of the gitconfig option and keeping the commandline option a simple boolean switch is probably fine, especially since delta reads gitconfig even in "standalone" mode. This won't break any existing aliases and there is no super compelling reason to have an automatic toggle via commandline flag since, unlike There should probably be a |
Right. If I'm understanding your suggestion correctly there's precedent for this -- it's similar to what we did to allow |
@aschmolck Delta now supports an env var named __dan_preexec_function () {
local columns=$(tput cols)
if [ $columns -ge 140 ]; then
export DELTA_FEATURES="side-by-side"
else
export DELTA_FEATURES=""
fi
}
typeset -ag preexec_functions;
preexec_functions=( __dan_preexec_function ${preexec_functions[@]} ) This is similar to wfxr/forgit#121 (comment) and may be relevant to #368; the shell code could also depend on I do wonder whether we would also want a |
There is __dan_preexec_function () {
local columns=$(tput cols)
if [ $columns -ge 140 ]; then
export GIT_PAGER="delta --side-by-side"
else
export GIT_PAGER="delta"
fi
}
typeset -ag preexec_functions;
preexec_functions=( __dan_preexec_function ${preexec_functions[@]} ) |
Here's a Fish shell version that listens to SIGWINCH: # Determine whether to use side-by-side mode for delta
function delta_sidebyside --on-signal WINCH
if test "$COLUMNS" -ge 120; and ! contains side-by-side "$DELTA_FEATURES"
set --global --export --append DELTA_FEATURES side-by-side
else if test "$COLUMNS" -lt 120; and contains side-by-side "$DELTA_FEATURES"
set --erase DELTA_FEATURES[(contains --index side-by-side "$DELTA_FEATURES")]
end
end
delta_sidebyside |
Coming to this thread from the distant future... I see almost universal enthusiasm for this proposal in the thread, plus at least one comment volunteering to work on it. Yet three years have passed and the issue remains open, nor does any PR link to it. Was this feature ever added and we just forgot to close the issue? Or was there some principled reason it never got implemented? |
Hi @cohml, it's that no-one worked on it. FWIW, I recently improved my shell tooling for toggling delta settings. This is what I've settled on currently: delta-toggle() {
eval "export DELTA_FEATURES=$(-delta-features-toggle $1 | tee /dev/stderr)"
} where So
|
Hi, many thanks for writing delta -- I've long longed for something like it and am very happy to discover it.
One question: side-by-side views are great for looking at more complicated diffs but require substantially more horizontal space, so are IMO not a good default for git diff with typical terminal widths. On the other hand it would be great to have easy access to side-by-side git diffs when doing a more thorough review with a full screen'ed terminal. Unfortunately I'm not aware to of a way to pass the
-s
flag through when using delta as git diff backend, or some other way to easily switch case-by-case.Assuming something like it does not already exist, how about a mechanism to provide context dependent side-by-side in git diff based on either a user-specified minimal column width or an easy way to pass flags through something like a
DELTA
env var (similar toLESS
)?The text was updated successfully, but these errors were encountered: