Skip to content

Commit 74a6437

Browse files
committed
Clear the scrollback every 120 seconds to release iTerm's memory
Fixes #4
1 parent 70837bd commit 74a6437

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,19 @@ func main() {
4949
clear()
5050
t := time.NewTicker(time.Second)
5151
defer t.Stop()
52+
i := 0
5253
for {
5354
width, height, err := window.Size()
5455
if err != nil {
5556
log.Fatalf("Cannot get window size: %v", err)
5657
}
5758
select {
5859
case <-t.C:
60+
i++
61+
if i%120 == 0 {
62+
// Clear scrollback to avoid iTerm from eating all the memory.
63+
cleanup()
64+
}
5965
render(dash, width, height-titleBarSize)
6066
case <-exit:
6167
render(dash, width, height-titleBarSize)
@@ -87,3 +93,7 @@ func clear() {
8793
func reset() {
8894
print("\033\133\061\073\061\110") // move cursor to 0x0
8995
}
96+
97+
func cleanup() {
98+
print("\033]1337;ClearScrollback\007")
99+
}

0 commit comments

Comments
 (0)