-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
draft: false | ||
title: 'How to stop AWS CLI clearing the screen' | ||
date: "2024-04-26T12:49:50Z" | ||
image: "/images/2024/04/h_IMG_1253.webp" | ||
thumbnail: "/images/2024/04/t_IMG_1105.webp" | ||
credit: "https://twitter.com/rmoff/" | ||
categories: | ||
- aws | ||
- pager | ||
--- | ||
|
||
:source-highlighter: rouge | ||
:icons: font | ||
:rouge-css: style | ||
:rouge-style: github | ||
|
||
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 | ||
|
||
<!--more--> | ||
|
||
== AWS CLI help text disappears when closed | ||
|
||
++++ | ||
<script src="https://asciinema.org/a/SvT2Ncm92T49vGMFcX5R6R7Ct.js" id="asciicast-656551" async="true"></script> | ||
++++ | ||
|
||
The fix: set `MANPAGER` (https://ashley.raiteri.net/stop-aws-cli-help-command-from-clearing-screen/[h/t]) | ||
|
||
[source,bash] | ||
---- | ||
export MANPAGER='less -isXF' | ||
---- | ||
|
||
++++ | ||
<script src="https://asciinema.org/a/MuEdcL9wSLSU6eFJKYr2mwcoQ.js" id="asciicast-656553" async="true"></script> | ||
++++ | ||
|
||
== 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 🤨 | ||
|
||
++++ | ||
<script src="https://asciinema.org/a/HeeDf3YOTO64sHzg7SyJBvoZf.js" id="asciicast-656555" async="true"></script> | ||
++++ | ||
|
||
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 https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-pagination.html#cli-usage-pagination-clientside[is documented] if you want to read more. | ||
|
||
[source,bash] | ||
---- | ||
export AWS_PAGER='less -isXF' | ||
---- | ||
|
||
or simply | ||
|
||
[source,bash] | ||
---- | ||
unset AWS_PAGER | ||
---- | ||
|
||
++++ | ||
<script src="https://asciinema.org/a/K5bCE9wXJDN5Bid6GHeWGrM8D.js" id="asciicast-656557" async="true"></script> | ||
++++ |
Binary file not shown.
Binary file not shown.