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). This uses a series of ANSI escape sequences. It doesn't need the window to be in the foreground (unlike some AppleScript solutions), either. 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
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |