rmoff's random ramblings
about talks

How to stop AWS CLI clearing the screen

Published Apr 26, 2024 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 🔗

Your browser does not support the video tag.

The fix: set MANPAGER (h/t)

export MANPAGER='less -isXF'
Your browser does not support the video tag.

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 🤨

Your browser does not support the video tag.

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
Your browser does not support the video tag.

Robin Moffatt

Robin Moffatt works on the DevRel team at Confluent. He likes writing about himself in the third person, eating good breakfasts, and drinking good beer.

Story logo

© 2025