Live data from Hacker News

Assorted less(1) tips

blog.thechases.com

11–20 of 56 posts

Re: Assorted less(1) tips

#11
Two things that have helped me a lot of times:

-L: skip preprocessing the input file. When opening rotated log files with the names like logfile.1, logfile.2... the default preprocessor on some distros will recognize them as man page source and helpfully pipe through nroff. If the file is largish this introduces an annoying pause. Using -L skips all that.

Ctrl-R as the first character of a search string will search for that literal string, not the regular expression. Nice if you have regex metacharacters in the search string and don't want to bother with escaping (and don't need the regex facilities, of course.)

Re: Assorted less(1) tips

#12
post #5

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. 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…

It 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.

Re: Assorted less(1) tips

#16
post #2

There -R to quit if the file is less than the screen size. There's also most as an alternative pager, and also glow (of course which, my fork of it is better) to render md files in the terminal.

Oh I see what you mean about glow, that looks like a nice UX improvement - I'm going to try your fork.

https://github.com/charmbracelet/glow/compare/master...fragm...

Re: Assorted less(1) tips

#17
post #9

Also -X or --no-init " ... desirable if the deinitialization string does something unnecessary, like clearing the screen." I prefer to not clear the screen. I usually want to continue to refer to something or even copy/paste from the content to my current command line.

And combined with -E, it'll quit immediately if the output is smaller than the terminal size. ...And combined with some of the other options in the post, my go-to has been "less -SEXIER" for a long time. Specifying E twice doesn't seem to do anything except make this easier to remember.

I'm reading it correctly that it will cause less to exit if you scroll until the end of file even if the file is larger than the terminal size?

Re: Assorted less(1) tips

#18
post #9

Earlier quoted context omitted.

And combined with -E, it'll quit immediately if the output is smaller than the terminal size. ...And combined with some of the other options in the post, my go-to has been "less -SEXIER" for a long time. Specifying E twice doesn't seem to do anything except make this easier to remember.

I'm reading it correctly that it will cause less to exit if you scroll until the end of file even if the file is larger than the terminal size?

Yeah; in both cases (text is larger or smaller than terminal) it makes "less" act the same as "more" with auto-exiting.

Re: Assorted less(1) tips

#19
post #5

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. 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…

With `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.

Re: Assorted less(1) tips

#20
post #9

Also -X or --no-init " ... desirable if the deinitialization string does something unnecessary, like clearing the screen." I prefer to not clear the screen. I usually want to continue to refer to something or even copy/paste from the content to my current command line.

And combined with -E, it'll quit immediately if the output is smaller than the terminal size. ...And combined with some of the other options in the post, my go-to has been "less -SEXIER" for a long time. Specifying E twice doesn't seem to do anything except make this easier to remember.

I hate -E. Quitting immediately does not do good things to my muscle memory. I’m using to hitting q to quit less when I am done. Now the q key becomes part of the input to the shell prompt (or worse if there’s a different tool invoking less and now q might be interpreted differently by that tool). I value the consistency of user interaction more than saving a keystroke.
Post reply on HN