/go-terminal-size

Get terminal size on Linux and Windows

Primary LanguageGoMIT LicenseMIT

Go terminal size

GoDoc Build Status Go Report Card

Features:

  • Get the size of the current terminal as rows and columns.
  • Listen on terminal size changes and receive the new size via a channel.
  • Supports Linux and Windows.

Installation

$ go get github.com/kopoli/go-terminal-size

Usage

For a complete example see _example/example.go.

Abbreviated example:

package main

import (
	"fmt"

	tsize "github.com/kopoli/go-terminal-size"
)

func main() {
	var s tsize.Size

	s, err := tsize.GetSize()
	if err == nil {
		fmt.Println("Current size is", s.Width, "by", s.Height)
	}
}

License

MIT license