Created
June 16, 2015 16:57
-
-
Save gajus/2f2d7cb9c674a8b8e86c to your computer and use it in GitHub Desktop.
Erase the scrollback history.
This file contains hidden or 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
| /** | |
| * Erase the scrollback history. | |
| */ | |
| function clearScrollback () { | |
| if (php_sapi_name() !== 'cli') { | |
| throw new Exception('Use of function in invalid interface context.'); | |
| } | |
| $term_program = getenv('TERM_PROGRAM'); | |
| // https://en.wikipedia.org/wiki/Terminal_(OS_X) | |
| if (strpos($term_program, 'Apple_Terminal') === 0) { | |
| echo chr(27) . '[3J'; | |
| // https://en.wikipedia.org/wiki/ITerm2 | |
| } else if (strpos($term_program, 'iTerm') === 0) { | |
| echo chr(27) . ']50;ClearScrollback' . chr(7); | |
| } else { | |
| throw new Exception('Unknown Termimanl program.'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment