Monitor file for changes
Closed this issue · 8 comments
Is there a way to use nvimpager
like less +F
or tail -f
(or tail -F
ideally) to watch log files as they grow?
Such a thing is currently not implemented and not possible. There are some notes about this limitation in the readme under "todo".
Notes for the future
- I think a good implementation of a
tail -f
like functionality should work for equally across real files and pipes. - It would be nice to stream from stdin directly to the nvim instance in nvimpager. This might be dependent on the upstream nvim issues linked in the readme.
- How well does nvim's reaload functionality work with keeping the cursor position?
The same is discussed for vimpager: rkitover/vimpager#247
That issue links to an interesting SO answer:
https://unix.stackexchange.com/a/417939/88313
It might be possible to use the autoread
option.
@plurry The following settings in the nvimpager init file might work but only for real files, not for pipes:
set autoread
au CursorHold * checktime
I quickly tried that just now and it didn't seem to work. Anyway, it's not critical for me. I just wanted to make sure I didn't miss some obvious option somewhere.
Thanks. Feel free to close if you'd like.
You might have to set updatetime
to a lower value or be more patient :)
An even better solution might be timers as they do not only fire once after the user did something:
set autoread
call timer_start(300, {id -> nvim_command("checktime")}, {"repeat": -1})
@plurry Have you tried running nvimpager
in watch
or entr
. I have no clue if it works, but it is probably worth a try
@cvoges12 The situation we are thinking about here is nvimpager waiting on some more text from a long running pipeline or a long log file that is being appended to. watch
restarts the program you give it so it would restart the whole long running pipeline or open the long logfile every n seconds. That is not what one wants.
I have implemented a version of follow mode based on the timer + checktime solution proposed above. It does not handle input via stdin from long running commands though. That is a limitation of nvimpager in general.