github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/readline/term.go (about) 1 package readline 2 3 import "os" 4 5 // GetTermWidth returns the width of Stdout or 80 if the width cannot be established 6 func GetTermWidth() (termWidth int) { 7 var err error 8 fd := int(os.Stdout.Fd()) 9 termWidth, _, err = GetSize(fd) 10 if err != nil { 11 termWidth = 80 // default to 80 with term width unknown as that is the de factor standard on older terms. 12 } 13 14 return 15 }