How to stop AWS CLI clearing the screen

Published by in Aws, Pager at https://rmoff.net/2024/04/26/how-to-stop-aws-cli-clearing-the-screen/

After a break from using AWS I had reason to reacquaint myself with it again today, and did so via the CLI. The AWS CLI is pretty intuitive and has a good helptext system, but one thing that kept frustrasting me was that after closing the help text, the screen cleared—so I couldn’t copy the syntax out to use in my command!

The same thing happened when I ran a command that returned output - the screen cleared.

Here’s how to fix either, or both, of these

AWS CLI help text disappears when closed 🔗

The fix: set MANPAGER (h/t)

export MANPAGER='less -isXF'

AWS CLI command output disappears when closed 🔗

Similar to the above, but a different solution, which confuses the issue when Googling :)

You run a command, you want to refer to the output, but as soon as you return to the command prompt it’s gone 🤨

The fix: make sure that AWS_PAGER is set to the correct invocation of less. Or other options, including setting --no-cli-pager argument. This is documented if you want to read more.

export AWS_PAGER='less -isXF'

or simply

unset AWS_PAGER