dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
22.76k stars 381 forks source link

🚀 Support following a file, like `less +F` #1556

Closed sanmai-NL closed 11 months ago

sanmai-NL commented 11 months ago

Files such as log files could be being written to continually. As far as I can tell, delta doesn't support the less +F functionality that handles this situation.

See https://man7.org/linux/man-pages/man1/less.1.html#COMMANDS:

F Scroll forward, and keep trying to read when the end of file is reached. Normally this command would be used when already at the end of the file. It is a way to monitor the tail of a file which is growing while it is being viewed. (The behavior is similar to the "tail -f" command.) To stop waiting for more data, enter the interrupt character (usually ^C). On systems which support poll(1) you can also use ^X or the character specified by the --intr option. If the input is a pipe and the --exit-follow-on-close option is in effect, less will automatically stop waiting for data when the input side of the pipe is closed.

dandavison commented 11 months ago

Hi @sanmai-NL,

As far as I can tell, delta doesn't support the less +F functionality that handles this situation.

I think it's the opposite! delta uses less as its pager, so you can do whatever your installed version of less can do. You can influence the less invocation via the LESS env var, and the DELTA_PAGER and PAGER env vars. See https://dandavison.github.io/delta/environment-variables.html#pager-environment-variables

I'm curious, why would you be following a file with delta? Do you have something writing diff output into a file? It's much more common to pipe diff output directly to delta.

Files such as log files could be being written to continually.

log files aren't usually in diff format, and delta is only designed for viewing diff format input.

sanmai-NL commented 11 months ago

Hi @dandavison,

In this case I wasn't using delta for its main new features. I went off your GitHub description ...

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

It turns out delta is instead

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

It appears there's no alternative available to less for the functionality I use in this case. Interesting, since the pager is directly exposed to potentially untrusted data.

dandavison commented 11 months ago

Or maybe "a syntax-highlighting pager that makes no effort to hide its implementation"?

In any case, the "for git, diff, and grep output" bit is key -- it will do odd and undefined things to arbitrary input.