Feature/poll active file for change
Allow automatic refresh from currently rendered and displayed local file.
New Flags
--watch, -f Enable File Watching (Defaults false) --interval, -i Interval in seconds to poll for file updates
This would fix #426 and is related to #416
Works like a charm 😍 what's the status on merging this into master?
I tried to fix a few bugs and added some enhancements to various charm projects. Unfortunately the response time once a PR is opened is not the best. So as there is no reaction on this PR since Dec 22, I would argue, it will not be merged any time soon
👀
This is a feature that would be useful to me.
In the meantime, I have achieved a similar (though less effective) solution using the inotify-tools package
MYFILE=log_file.txt
while inotifywait -e modify $MYFILE; do
clear
cat $MYFILE | glow
done
Sure. Or using entr. I keep on using my patched version of glow though :)
ls *.md | entr glow yourfile.md
^ bumping this PR
The fact that this feature has been ready since December last year and still hasn't been added is a shame as it's a wonderful concept!
^ bumping this PR
The fact that this feature has been ready since December last year and still hasn't been added is a shame as it's a wonderful concept!
I almost forgot about this open PR. I went from being motivated to work on issues here, to Beeing realistic and did not expect it to be merged soon. Turns out i was right 😀 I believe I also asked the maintainers if there is anything missing for this to be considered. It might not be on their agenda. But even then I would expect the PR to be handled somehow. Rejecting at least.
This works nicely for me.
I uninstalled the upstream glow and will be using your version for the time being. It's vital to have live rendering while writing a markdown document.
I noticed that the file watcher only works in TUI mode, i.e. when invoked with glow and then navigating to the file via the TUI.
I tried to do this at first glow --watch --interval 1 --pager. When it did not reload on changes, I noticed that glow --help mentioned it only works in TUI mode.
This may be a bug indeed. Not sure if am willing to spend more time on this to make it not only work in tui mode.
Sure. Or using entr. I keep on using my patched version of glow though :)
ls *.md | entr glow yourfile.md
Adding skim and some extra entr functionality for fuzzy-finding and a pretty experience:
sk | entr -c glow /_
@meowgorithm Is there still need for this, or should I close it ?
Thanks for flagging this, @deicon. We'll take a look at this and let you know of week.
I think a polling solution should only be a fallback for monitoring files. Ideally we use one of the platform's native ways to monitor filesystem events: kqueue, inotify, and so on. There's an fsnotify package that abstracts this functionality for each platform, but it doesn't have a polling fallback yet. Maybe this would be a good contribution there?
There are also additional problems that we uncovered while experimenting with filesystem monitoring:
- Partial writes: we will need to figure out a way to detect when a file has been fully updated, not when writing to it starts. Otherwise you render incomplete content.
- Some editors & tools will not actually overwrite the contents of a file, but write to a temporary file first, then move it in place. In such situations the original file typically briefly disappears, along with all the monitoring you set up.