cli/pkg/iostreams/tty_size.go
Mislav Marohnić d02f184bd1 go fmt
2021-12-02 16:12:24 +01:00

20 lines
340 B
Go

//go:build !windows
// +build !windows
package iostreams
import (
"os"
"golang.org/x/term"
)
// ttySize measures the size of the controlling terminal for the current process
func ttySize() (int, int, error) {
f, err := os.Open("/dev/tty")
if err != nil {
return -1, -1, err
}
defer f.Close()
return term.GetSize(int(f.Fd()))
}