ymattw / ydiff

View colored, incremental diff in workspace or from stdin, side by side and auto paged.
Other
877 stars 62 forks source link

Configurable pager behaviour (auto/always/never) #82

Closed shaicoleman closed 5 months ago

shaicoleman commented 5 years ago

ydiff currently uses the --quit-if-one-screen option of less.

Please make the pager behaviour configurable, so the pager can be always enabled or always disabled.

ymattw commented 5 years ago

I think the default option passed to less -FRSX --shift 1 is sensible, curious what's your use case for disabling -F / --quit-if-one-screen?

shaicoleman commented 5 years ago

Depends on the situation:

ymattw commented 5 years ago

I see, some of the use cases do make sense. Unfortunately the default options for less were (stolen) from git source code, changing that might break other users. A workaround for you is to reset the LESS environment variable (e.g. set to -R), either from cmd line or in your script, to override the behavior.

If the workaround is still annoying to you, feel free to send me a pull request. But I would prefer a logic to respect PAGER environment variable, rather than introducing new flags (auto/always/never).

krader1961 commented 5 years ago

@shaicoleman FWIW, I too don't like the default --quit-if-one-screen behavior for the reasons you cited. As @ymattw suggests I get my preferred behavior by having a comprehensive LESS env var:

--HILITE-UNREAD --LONG-PROMPT --RAW-CONTROL-CHARS --chop-long-lines --ignore-case --jump-target=4 --no-init --quiet --search-skip-screen --shift=0 --squeeze-blank-lines --window=-2 --shift=.3 --prompt==%f\$ --prompt=M?f%f:*stdin*.  F %i/%m  .?ltL %lt-%lb/%L:?pt%pt\%:?btByte %bt:-...  C %c  ?Pt%Pt:?pt%pt:\?\?..\%?e EOF.\$

For the infrequent times that I don't want a pager I also don't want a side-by-side diffs so I just use git diff. It's not clear to me that a "don't pipe through a pager" option would be useful enough to justify even a few lines of additional code.

shaicoleman commented 5 years ago

@ymattw, @krader1961, thanks, setting the LESS variable fixes it for my needs, it should probably be mentioned when running ydiff --help

jesseduffield commented 4 years ago

@ymattw I'm adding support for custom pagers to lazygit (examples) and I've got a use case for a --paging=never flag. I don't want ydiff using less at all, and I'm not aware of any way to make less unconditionally just render to stdout and exit. Happy to put up a PR

jesseduffield commented 4 years ago

Worth noting that git diff | ydiff -p cat actually still pipes to less, unlike what the docs say

jesseduffield commented 4 years ago

scratch that, if I download ydiff directly it works, but it looks like the pip and homebrew versions aren't up to date with master

mscottnelson commented 4 years ago

I ran into the same thing as @jesseduffield while trying to get ydiff hooked up to fzf via https://github.com/bigH/git-fuzzy. Any chance we can get a version bump?

mscottnelson commented 4 years ago

I'm having trouble making this feasible: pipe side-by-side and colorized output to another process (in this case, fzf preview). Mostly because there doesn't appear to be a way to bypass pipe-detection

ghost commented 3 years ago

Hello, I am using ydiff as :ydiff -w 0 -s -p less, however the less page does not have colors. It appears has:

ESC[36mOnly in FolderA
ESC[0mESC[33mESC[0mESC[33mESC[0m

If I pass -p cat it works fine, but I would like to have one page per file. Is it possible to make less interpret the colors?

ghost commented 3 years ago

Hello, I am using ydiff as :ydiff -w 0 -s -p less, however the less page does not have colors. It appears has:

ESC[36mOnly in FolderA
ESC[0mESC[33mESC[0mESC[33mESC[0m

If I pass -p cat it works fine, but I would like to have one page per file. Is it possible to make less interpret the colors?

This was solved with -p less -o '-R'. Sorry for the inconvenience!

ymattw commented 3 years ago

-p overrides the default pager (less) and also the default option for it, just drop -p less, it should work.

On Sat, Sep 18, 2021 at 6:44 PM mamanunu @.***> wrote:

Hello, I am using ydiff as : ydiff -w 0 -s -p less, however the less page does not have colors. It appears has:

ESC[36mOnly in FolderA ESC[0mESC[33mESC[0mESC[33mESC[0m

If I pass -p cat it works fine, but I would like to have one page per file. Is it possible to make less interpret the colors?

This was solved with -p less -o '-R'. Sorry for the inconvenience!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ymattw/ydiff/issues/82#issuecomment-922337961, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKXRD7KHPJYSPPOOWYEUQ3UCS6XRANCNFSM4GSXG7YA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.