{"id":16096479,"url":"https://github.com/aymanbagabas/go-pty","last_synced_at":"2025-03-16T08:32:24.627Z","repository":{"id":196217260,"uuid":"669920260","full_name":"aymanbagabas/go-pty","owner":"aymanbagabas","description":"Cross platform Go Pty interface","archived":false,"fork":false,"pushed_at":"2024-12-13T14:34:35.000Z","size":146,"stargazers_count":39,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-16T00:11:22.518Z","etag":null,"topics":["cross-platform","go","golang","pseudoterminal","pty","ssh","terminal","tty"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aymanbagabas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["aymanbagabas"],"patreon":"aymanbagabas","custom":["https://www.paypal.me/aymanbagabas","https://www.buymeacoffee.com/aymanbagabas"]}},"created_at":"2023-07-23T21:23:57.000Z","updated_at":"2025-03-14T13:04:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"2b8aebf3-384d-4503-b6cb-4356c7e13b24","html_url":"https://github.com/aymanbagabas/go-pty","commit_stats":null,"previous_names":["aymanbagabas/go-pty"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aymanbagabas%2Fgo-pty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aymanbagabas%2Fgo-pty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aymanbagabas%2Fgo-pty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aymanbagabas%2Fgo-pty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aymanbagabas","download_url":"https://codeload.github.com/aymanbagabas/go-pty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243846976,"owners_count":20357294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-platform","go","golang","pseudoterminal","pty","ssh","terminal","tty"],"created_at":"2024-10-09T17:14:03.194Z","updated_at":"2025-03-16T08:32:24.341Z","avatar_url":"https://github.com/aymanbagabas.png","language":"Go","funding_links":["https://github.com/sponsors/aymanbagabas","https://patreon.com/aymanbagabas","https://www.paypal.me/aymanbagabas","https://www.buymeacoffee.com/aymanbagabas"],"categories":[],"sub_categories":[],"readme":"# Go Pty\n\n\u003cp\u003e\n    \u003ca href=\"https://github.com/aymanbagabas/go-pty/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/release/aymanbagabas/go-pty.svg\" alt=\"Latest Release\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://pkg.go.dev/github.com/aymanbagabas/go-pty?tab=doc\"\u003e\u003cimg src=\"https://godoc.org/github.com/golang/gddo?status.svg\" alt=\"GoDoc\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/aymanbagabas/go-pty/actions\"\u003e\u003cimg src=\"https://github.com/aymanbagabas/go-pty/workflows/build/badge.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nGo-Pty is a package for using pseudo-terminal interfaces in Go. It supports Unix PTYs and Windows through [ConPty](https://learn.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session).\n\n## Why can't we just use os/exec?\n\nWindows requires updating the process running in the PTY with a [special attribute](https://learn.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session) to enable ConPty support. This is not possible with os/exec see [go#62708](https://github.com/golang/go/issues/62708) and [go#6271](https://github.com/golang/go/pull/62710). On Unix, `pty.Cmd` is just a wrapper around `os/exec.Cmd` that sets up the PTY.\n\n## Usage\n\n```sh\ngo get github.com/aymanbagabas/go-pty\n```\n\nExample running `grep`\n\n```go\npackage main\n\nimport (\n\t\"io\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/aymanbagabas/go-pty\"\n)\n\nfunc main() {\n\tpty, err := pty.New()\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to open pty: %s\", err)\n\t}\n\n\tdefer pty.Close()\n\tc := pty.Command(\"grep\", \"--color=auto\", \"bar\")\n\tif err := c.Start(); err != nil {\n\t\tlog.Fatalf(\"failed to start: %s\", err)\n\t}\n\n\tgo func() {\n\t\tpty.Write([]byte(\"foo\\n\"))\n\t\tpty.Write([]byte(\"bar\\n\"))\n\t\tpty.Write([]byte(\"baz\\n\"))\n\t\tpty.Write([]byte{4}) // EOT\n\t}()\n\tgo io.Copy(os.Stdout, pty)\n\n\tif err := c.Wait(); err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\nRefer to [./examples](./examples) for more examples.\n\n## Credits\n\n- [creack/pty](https://github.com/creack/pty/): support for Unix PTYs\n- [microsoft/hcsshim](https://github.com/microsoft/hcsshim): Windows ConPty implementation\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faymanbagabas%2Fgo-pty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faymanbagabas%2Fgo-pty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faymanbagabas%2Fgo-pty/lists"}