- HOW TO USE THE SCROLLBACK BUFFERS TO CLEAR UP SPACE ON MAC CODE
- HOW TO USE THE SCROLLBACK BUFFERS TO CLEAR UP SPACE ON MAC SERIES
- HOW TO USE THE SCROLLBACK BUFFERS TO CLEAR UP SPACE ON MAC FREE
Hopefully, your Mac is free of malware, but you should always make sure it’s protected. If MacKeeper finds any suspicious files, take the recommended actions.Open MacKeeper, and select Antivirus from the menu.It’s worth running a scan with MacKeeper just to be sure. If you’re flashing your DNS cache because you’re experiencing problems, you might have malware on your Mac. One solution is to clear your Mac’s DNS cache. But if it gets corrupted, then you can run into problems loading sites, with 404 errors being common. It works quietly in the background, sending you to the right websites when you ask for them. Notice they don't use \e3J, hence why clear only clears the screen, but not the scrollback.Most of the time, your Mac’s DNS cache isn’t something you need to worry about. We can re-create the same output with printf '\e[H \e2J': $ printf '\e[H \e2J' | xxd All it seems to do is product some output, which we can inspect with xxd: $ clear | xxd These control sequences are actually how the built-in clear ( /usr/bin/clear) command works. This could have been more explicitly written as \e[1 1H A sequence such as CSI 5H is a synonym for CSI 1 5H as well as CSI 17 H is the same as CSI 17H and CSI 17 1H The values are 1-based, and default to 1 (top left corner) if omitted. This is an instance of the "CUP - Cursor Position" command, which has the form CSI n m H, The start of an escape sequence ( \e), containing a control sequence ( [) with argument H. Hence the need for the \e[2J command above.
If n is 3, clear entire screen and delete all lines saved in the scrollback buffer (this feature was added for xterm and is supported by other terminal applications)."ĭespite the description on Wikipedia, it appears that this isn't actually clearing the screen in iTerm and the default Terminal, only the scrollback buffer was cleared. The n value is set to 3 in this case, which invokes the third variant: This is an instance of the "ED – Erase in Display" command, which has the form CSI n J The start of an escape sequence ( \e), containing a control sequence ( [) with argument 3J If n is 2, clear entire screen (and moves cursor to upper left on DOS ANSI.SYS).
printf can print an this character using \e (or by its octal value \033, or its hex value \x1B). Each ANSI escape sequence starts with the "ESC" (escape) character, it's a non-printable ASCII character (meaning it has no visual glyph representation like 1 or a).
HOW TO USE THE SCROLLBACK BUFFERS TO CLEAR UP SPACE ON MAC SERIES
This uses a series of ANSI escape sequences. It doesn't need the window to be in the foreground (unlike some AppleScript solutions), either.
HOW TO USE THE SCROLLBACK BUFFERS TO CLEAR UP SPACE ON MAC CODE
Here's code that works for both macOS' Terminal, and iTerm2. If you put this in a shell script that you don’t know for certain will only ever be run with Terminal, you should check that $TERM_PROGRAM is Apple_Terminal before sending it.) (The clear command looks up the appropriate sequence for clearing the screen for the current terminal, but the “erase scroll-back” escape sequence is custom and must be hard-coded. This allows you to erase one or the other, or both by sending two escape sequences.įor example, you can clear the screen and the scroll-back with the following shell command: clear & printf '\e[3J' Note that this only erases the scroll-back, not the screen. The ED command, described in the VT100 manual, accepts these values for the Ps parameter:Ġ Erase from the active position to the end of the screenġ Erase from start of the screen to the active positionģ Erase the scroll-back (aka “Saved Lines”)
Terminal supports an extension of the ED (Erase in Display) escape sequence to erase the scroll-back.