4 ms·
Surprised they missed follow! It’s a bit odd to use, but once you get used to it it’s better than tail in many circumstances IMO. `less +F` starts less followin
by teeray 9mo ago
Surprised they missed follow! It’s a bit odd to use, but once you get used to it it’s better than tail in many circumstances IMO. `less +F` starts less following stdin or whatever file argument you’ve provided. <C-c> breaks following, allowing you to search around a business-as-usual `less` session. Hitting `F` (that’s uppercase) starts following again. Yes, you can just start following within a session with `F` too if you forgot to add +F to the `less` invocation.
- sprt 9mo agoI'm so mad that I didn't know the hitting F thing!
- layer8 9mo agoIt would be nice to have a mode that follows in the sense of automatically picking up new output, but that simultaneously would let you navigate around, similar to how terminals behave. Then you’d only need an autoscroll toggle for when you’re at the bottom.
- gerdesj 9mo agoTake a look at "lnav" ...
- tstack 9mo agoTo elaborate on this, lnav (https://lnav.org https://lnav.org) is always polling files to check for new data and will load it in automatically. It does not require the user to do anything. As far as following the tail of the file: if the focused line is at the end of the file, the display will scroll automatically; otherwise, the display will stick to the current position. Also, if there is a search active, matches in the new data will be found and highlighted.
- 1718627440 9mo ago> autoscroll toggle This exists on IBM keyboards and is called 'Pause'. Sadly most programs don't use it.
- joombaga 9mo agoWith `tail` you can press enter a few times to put some empty lines after the last line. This is useful e.g. when you trigger a function multiple times and want to easily see line groups from each attempt. It's the only reason I still use `tail` for following when `less` is available.
- teeray 9mo agoA visual mark would be nice, agreed. I haven't tried it, but I wonder if you could approximate it with the bookmarking feature that less(1) does have. It wouldn't be visible, but it would scroll to a consistent mark.
- vladvasiliu 9mo agoI usually use tail when I need to do some ad-hoc log following. Having to set bookmarks and remember them is a PITA I can usually do without. If I'm looking at "normal" log output, it's usually set up in a nice aggregator somewhere, where I can easily exclude noise and otherwise uninteresting output.
- CBLT 9mo agoIf you're following a pipe (such as `kubectl logs | less +F`), <C-c> is sent to all processes in a pipeline, so it stops less from following and it stops the other process entirely. Then you can't start following again with F, or load more data in with G. Less provides an alternative of <C-x> to stop following, but that is intercepted by most shells.
- vbezhenar 9mo ago> Less provides an alternative of <C-x> to stop following, but that is intercepted by most shells. WoW, thanks a lot! That was my pain for many years. C-x works in Gnome Console just fine.
- mananaysiempre 9mo agoFunnily enough, it literally tells you right there on the bottom line: “Waiting for data... (^X or interrupt to abort)”. No shame in not noticing, just another case of blindness to long-familliar messages I guess.
- mananaysiempre 9mo agoBy the shell or by the kernel’s terminal discipline or by the terminal emulator? AFAIU the shell is basically out of the picture while `less` is running.
- CBLT 9mo agoI can <C-z> while less is running to background that process using the shell, so the shell is clearly not completely gone. I might be misremembering, but I think I just had to rebind <C-x> in zsh to get less working.
- obezyian 9mo agoI think by "out of the picture" PP meant that the shell is not processing the input, not that it has exited. C-z is not processed by the shell but by the terminal "infrastructure". You can disable it, or change the key binding, and a lot more, with stty(1).
- xg15 9mo agoMaybe OT, but I thought for a long time that "follow" was some sophisticated file descriptor trickery that required you to somehow "stream" the file while reading and would therefore be incompatible with opening a file "normally". My mind was blown when finding out its really just "keep on polling after EOF". Meaning there is absolutely no difference between opening a file normally and "following" a file - and software could easily switch between the two "modes" on the fly.
- tstack 9mo ago> It’s a bit odd to use I would say it's a bad UX and not just odd. I can't see any benefit to making it modal. It should just load new data as it becomes available without making the user do anything.