2

When piping command output into less, I'll scroll to the bottom of the output using the mouse and I'll find less gets stuck in forward scrolling, preventing me from scrolling back through output. This is the same behaviour as pressing F. Is there a way to unlock less from forward scroll?

Reproduce: docker-compose up | less followed by pressing F

3

Yes.

I believe less actually says "Waiting for data... (interrupt to abort)" upon entering this mode.

"Interrupt" means "Press Ctrl+C". This will send the INT (interrupt) signal to the less process.

Ctrl+C will send the INT signal to whatever program currently is in the foreground in the shell, just like doing kill -s INT pid from another terminal would do (where pid might be the process ID of the less process, for example). Fun fact.

  • 1
    My hero! Has been bothering me for weeks. It looks like less is forwarding the Interrupt to the child process, is there a way to prevent this? I'd like to be able to scroll back, but for my child process to keep on running. – retrohacker Jan 1 '17 at 21:18
  • 4
    @retrohacker ( trap '' INT && somecommand ) | less, i.e. ignore the INT signal in the sub-shell running the command. – Kusalananda Jan 1 '17 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.