commit | 87da17124bbb35ef6615824eb0d15e99718fd227 | [log] [tgz] |
---|---|---|
author | Keith Rarick <kr@xph.us> | Sat Mar 16 18:19:07 2013 -0700 |
committer | Keith Rarick <kr@xph.us> | Sat Mar 16 18:25:38 2013 -0700 |
tree | 70beb44872f5329f3edcc7d50947d0d3459d6eba | |
parent | c46bdbf4af2e43e5f163092037ec27e9e9aee1f3 [diff] |
get rows and cols in a tty
Pty is a Go package for using unix pseudo-terminals.
go get github.com/kr/pty
package main import ( "github.com/kr/pty" "io" "os" "os/exec" ) func main() { c := exec.Command("grep", "--color=auto", "bar") f, err := pty.Start(c) if err != nil { panic(err) } go func() { f.Write([]byte("foo\n")) f.Write([]byte("bar\n")) f.Write([]byte("baz\n")) f.Write([]byte{4}) // EOT }() io.Copy(os.Stdout, f) }