Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

PTY interface for Go

branch: master
Octocat-spinner-32 .gitignore initial
Octocat-spinner-32 License add MIT license; closes #2
Octocat-spinner-32 README.md remove obsolete caveat
Octocat-spinner-32 doc.go define public symbols without build constraints
Octocat-spinner-32 ioctl.go Portable ioctl calls
Octocat-spinner-32 ioctl_bsd.go Portable ioctl calls
Octocat-spinner-32 ioctl_linux.go Portable ioctl calls
Octocat-spinner-32 mktypes.bash Portable ioctl calls
Octocat-spinner-32 pty_darwin.go add generated ztypes_arm.go and ztypes_freebsd_arm.go
Octocat-spinner-32 pty_freebsd.go add generated ztypes_arm.go and ztypes_freebsd_arm.go
Octocat-spinner-32 pty_linux.go add generated ztypes_arm.go and ztypes_freebsd_arm.go
Octocat-spinner-32 pty_unsupported.go Portable ioctl calls
Octocat-spinner-32 run.go set controlling tty for new process; closes #8
Octocat-spinner-32 types.go Portable ioctl calls
Octocat-spinner-32 types_freebsd.go add generated ztypes_arm.go and ztypes_freebsd_arm.go
Octocat-spinner-32 util.go get rows and cols in a tty
Octocat-spinner-32 ztypes_386.go Portable ioctl calls
Octocat-spinner-32 ztypes_amd64.go Portable ioctl calls
Octocat-spinner-32 ztypes_arm.go add generated ztypes_arm.go and ztypes_freebsd_arm.go
Octocat-spinner-32 ztypes_freebsd_386.go add generated ztypes_arm.go and ztypes_freebsd_arm.go
Octocat-spinner-32 ztypes_freebsd_amd64.go add generated ztypes_arm.go and ztypes_freebsd_arm.go
Octocat-spinner-32 ztypes_freebsd_arm.go add generated ztypes_arm.go and ztypes_freebsd_arm.go
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.