bat icon indicating copy to clipboard operation
bat copied to clipboard

Is there a way to run bat with -f (similar to tail -f) to follow a file ?

Open mxaddict opened this issue 1 year ago • 3 comments

Is there a way to run bat with -f (similar to tail -f) to follow a file ?

mxaddict avatar Aug 09 '24 05:08 mxaddict

As far as I'm aware it does not have an option to do it itself, however you can combine it with tail -f. From the README:

bat can be combined with tail -f to continuously monitor a given file with syntax highlighting.

tail -f /var/log/pacman.log | bat --paging=never -l log

Note that we have to switch off paging in order for this to work. We have also specified the syntax explicitly (-l log), as it can not be auto-detected in this case.

Alessandro201 avatar Aug 09 '24 10:08 Alessandro201

If tail/follow were an option with bat I would definitely use it.

scottchiefbaker avatar Mar 12 '25 22:03 scottchiefbaker

I just learned that less has "following" built in. You can either press F after running less to enter "follow" mode or use:

less +F /var/log/stuff.log

Of course you don't get any of the niceness of bat, so this would definitely be a welcome feature in bat.

scottchiefbaker avatar Sep 08 '25 20:09 scottchiefbaker