Skip to content
PTY interface for Go
Go Shell
Find file
Latest commit f7ee69f Oct 7, 2015 @jonboulle jonboulle run: don't override supplied SysProcAttr
If we're passed an exec.Cmd that already has a configured SysProcAttr,
Start was obliterating it by overwriting it with a new struct in order
to set `Setctty` and `Setsid`. Instead, just adjust the parameters that
we need.
Failed to load latest commit information.
.gitignore initial May 3, 2011
License add MIT license; closes #2 Apr 5, 2012
README.md remove obsolete caveat Dec 3, 2012
doc.go define public symbols without build constraints Mar 4, 2014
ioctl.go Portable ioctl calls Mar 14, 2014
ioctl_bsd.go Portable ioctl calls Mar 14, 2014
mktypes.bash Portable ioctl calls Mar 14, 2014
pty_darwin.go add generated ztypes_arm.go and ztypes_freebsd_arm.go Mar 16, 2014
pty_freebsd.go add generated ztypes_arm.go and ztypes_freebsd_arm.go Mar 16, 2014
pty_linux.go Remove uintptr(...) Dec 4, 2014
pty_unsupported.go Portable ioctl calls Mar 14, 2014
run.go run: don't override supplied SysProcAttr Oct 7, 2015
types.go Portable ioctl calls Mar 14, 2014
types_freebsd.go add generated ztypes_arm.go and ztypes_freebsd_arm.go Mar 16, 2014
util.go get rows and cols in a tty Mar 16, 2013
ztypes_386.go Portable ioctl calls Mar 14, 2014
ztypes_amd64.go Portable ioctl calls Mar 14, 2014
ztypes_arm.go add generated ztypes_arm.go and ztypes_freebsd_arm.go Mar 16, 2014
ztypes_arm64.go Prevent arm64 file to be compiled anywhere else. Fixed #32. May 11, 2015
ztypes_freebsd_386.go add generated ztypes_arm.go and ztypes_freebsd_arm.go Mar 16, 2014
ztypes_freebsd_amd64.go add generated ztypes_arm.go and ztypes_freebsd_arm.go Mar 16, 2014
ztypes_freebsd_arm.go add generated ztypes_arm.go and ztypes_freebsd_arm.go Mar 16, 2014
ztypes_ppc64.go Add support for Power (ppc64, ppc64le) and System z (s390x) Nov 21, 2014
ztypes_ppc64le.go Add support for Power (ppc64, ppc64le) and System z (s390x) Nov 21, 2014
ztypes_s390x.go Add support for Power (ppc64, ppc64le) and System z (s390x) Nov 21, 2014

README.md

pty

Pty is a Go package for using unix pseudo-terminals.

Install

go get github.com/kr/pty

Example

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)
}
Something went wrong with that request. Please try again.