Feature request: reload the current file (keybinding) and optional auto-reload
Motivation
When using bat to tail/live-inspect files (logs, generated configs, source files being edited by another process), there is currently no way to refresh the displayed content without quitting and re-running bat. It would be very useful to be able to reload the current file in place.
Proposed features
-
Manual reload via keybinding
- Add a keybinding (e.g.
r or Ctrl+R) that reloads the current file from disk and re-renders the view.
- Should work even when no search term is active.
-
Auto-reload (follow / watch mode)
- Add an option such as
--follow / --watch (or a keybinding that toggles it) that watches the file for changes and automatically reloads the content.
- This would make
bat usable like tail -f for file monitoring.
-
Cursor / scroll position preservation
- After a reload, restore the current scroll position (and selection/active search match if possible) so the view doesn't jump back to the top.
- At minimum, attempt to keep the line that was on screen at the time of reload at the same screen offset.
Notes / considerations
- Restoring the exact scroll position is complicated if the file changes in length or content above the visible region (like in a text editor); a best-effort restoration based on the line number is acceptable.
- This interacts with
bat's pager (less) — reload may need to be implemented by feeding fresh content to the pager or via a pager-agnostic approach. Worth clarifying with maintainers how the pager integration should work.
- For auto-reload, polling the file for mtime/size changes (like
tail -f) or an inotify-based approach could be considered.
Prior art
less supports R to reread the current file (hides the control characters) — but does not reload changes from disk the way requested here.
tail -f / --retry reloads on change.
Thanks for considering this!
Feature request: reload the current file (keybinding) and optional auto-reload
Motivation
When using
batto tail/live-inspect files (logs, generated configs, source files being edited by another process), there is currently no way to refresh the displayed content without quitting and re-runningbat. It would be very useful to be able to reload the current file in place.Proposed features
Manual reload via keybinding
rorCtrl+R) that reloads the current file from disk and re-renders the view.Auto-reload (follow / watch mode)
--follow/--watch(or a keybinding that toggles it) that watches the file for changes and automatically reloads the content.batusable liketail -ffor file monitoring.Cursor / scroll position preservation
Notes / considerations
bat's pager (less) — reload may need to be implemented by feeding fresh content to the pager or via a pager-agnostic approach. Worth clarifying with maintainers how the pager integration should work.tail -f) or an inotify-based approach could be considered.Prior art
lesssupportsRto reread the current file (hides the control characters) — but does not reload changes from disk the way requested here.tail -f/--retryreloads on change.Thanks for considering this!