How can I erase the scroll-back in a terminal using Go?
In OS X using Terminal, I can run:
$ print '\e[3J'
and it will "Erase the scroll-back (aka 'Saved Lines')." Great!
But, in Go, when I run:
exec.Command("print", `\e[3J`).CombinedOutput()
I get the error that exec: "print": executable file not found in $PATH
, which makes sense:
$ type -a print
print is a shell builtin
The helpful Gophers in Slack mentioned I should look into communicating the the terminal app directly (whether it be Terminal, iTerm, iTerm2, etc.). However, I'm at a loss even after looking at this: https://www.iterm2.com/documentation-scripting.html