github.com/markusbkk/elvish@v0.0.0-20231204143114-91dc52438621/pkg/sys/sys.go (about) 1 // Package sys provide system utilities with the same API across OSes. 2 // 3 // The subpackages eunix and ewindows provide OS-specific utilities. 4 package sys 5 6 import ( 7 "os" 8 9 "github.com/mattn/go-isatty" 10 ) 11 12 const sigsChanBufferSize = 256 13 14 // NotifySignals returns a channel on which all signals gets delivered. 15 func NotifySignals() chan os.Signal { return notifySignals() } 16 17 // SIGWINCH is the window size change signal. 18 const SIGWINCH = sigWINCH 19 20 // Winsize queries the size of the terminal referenced by the given file. 21 func WinSize(file *os.File) (row, col int) { return winSize(file) } 22 23 // IsATTY determines whether the given file is a terminal. 24 func IsATTY(file *os.File) bool { 25 return isatty.IsTerminal(file.Fd()) || isatty.IsCygwinTerminal(file.Fd()) 26 }