{"id":15395294,"url":"https://github.com/cocoa-xu/expty","last_synced_at":"2025-04-15T17:00:11.633Z","repository":{"id":104806956,"uuid":"607912060","full_name":"cocoa-xu/ExPTY","owner":"cocoa-xu","description":"Fork pseudoterminals in Elixir","archived":false,"fork":false,"pushed_at":"2025-02-10T16:35:34.000Z","size":1704,"stargazers_count":20,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T16:59:54.549Z","etag":null,"topics":["elixir","pseudoterminal","tty"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cocoa-xu.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}},"created_at":"2023-02-28T23:30:34.000Z","updated_at":"2025-02-10T16:34:55.000Z","dependencies_parsed_at":"2024-06-14T16:02:08.491Z","dependency_job_id":"a0fdf6d7-8dd2-438b-8ccf-b23b22a3efaf","html_url":"https://github.com/cocoa-xu/ExPTY","commit_stats":{"total_commits":86,"total_committers":2,"mean_commits":43.0,"dds":"0.12790697674418605","last_synced_commit":"befe898e70e63d631ddeeb9552551abf80322fbd"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cocoa-xu%2FExPTY","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cocoa-xu%2FExPTY/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cocoa-xu%2FExPTY/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cocoa-xu%2FExPTY/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cocoa-xu","download_url":"https://codeload.github.com/cocoa-xu/ExPTY/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249116231,"owners_count":21215142,"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":["elixir","pseudoterminal","tty"],"created_at":"2024-10-01T15:27:31.694Z","updated_at":"2025-04-15T17:00:11.505Z","avatar_url":"https://github.com/cocoa-xu.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"**(Warning: this project is still WIP, there are a lot of things (like proper cleanups) not done yet, and right now it shows a minimal working product (without proper cleanups yet!) with Kino. Use at your own risk.**\n\n**Any help/PR is welcome!**\n\n# ExPTY\n\n`ExPTY` fills the gap where executables spawned by `Port` do not have a tty available to them.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e Module \u003c/td\u003e \u003ctd\u003e Example \u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e \u003ccode\u003eExPTY\u003c/code\u003e \u003c/td\u003e\n\u003ctd\u003e\n\n```elixir\niex\u003e pty = ExPTY.spawn(\"tty\", [], on_data: fn _, _, data -\u003e IO.write(data) end)\n#PID\u003c0.229.0\u003e\n/dev/ttys001\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e \u003ccode\u003ePort\u003c/code\u003e \u003c/td\u003e\n\u003ctd\u003e\n\n```elixir\niex\u003e Port.open({:spawn, \"tty\"}, [:binary])\n#Port\u003c0.5\u003e\niex\u003e flush()\n{#Port\u003c0.5\u003e, {:data, \"not a tty\\n\"}}\n:ok\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nMost importantly, and as a consequence of the point above, we can now forward all data to somewhere else (e.g., via WebSocket to LiveBook) have a full terminal experience.\n\n## Example\n\n```elixir\ndefmodule Example do  \n  def run do\n    {:ok, pty} =\n      ExPTY.spawn(\"tty\", [],\n        name: \"xterm-color\",\n        cols: 80,\n        rows: 24,\n        on_data: __MODULE__,\n        on_exit: __MODULE__\n      )\n\n    pty\n  end\n\n  def on_data(ExPTY, _erl_pid, data) do\n    IO.write(data)\n  end\n\n  def on_exit(ExPTY, _erl_pid, exit_code, signal_code) do\n    IO.puts(\"exit_code=#{exit_code}, signal_code=#{signal_code}\")\n  end\nend\n```\n\n## Installation\n\n### Unix\nFor Unix systems it's pretty much what you would expect, a working C/C++ toolchain, CMake, Make.\n\n### Windows\nFor Windows users, if you're not using Livebook, it's also the same as installing any other NIF libraries. \n  \n**However, if you're trying to install it on a Livebook, you need to set up some environment variables.**\n\nNormally, these environment variables would be set by `vcvarsall.bat` in your cmd (or powershell, or any other shell), but here we have to do it manually:\n\n- Open the `x64 Native Tools Command Prompt` (on 64-bit system) or `x86 Native Tools Command Prompt` (on 32-bit system)\n- In the command prompt window, type `set`, and you will see all the environment variables\n- Copy the output printed by `set` command, and store them in a variable (say `env`) in the setup cell in your livebook\n- export these environment variables before `Mix.install` using the following code\n\n```elixir\nEnum.each(String.split(env, \"\\n\"), fn env_var -\u003e\n  case String.split(env_var, \"=\", parts: 2) do\n    [name, value] -\u003e\n      System.put_env(name, value)\n    _ -\u003e :ok\n  end\nend)\n```\n\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed\nby adding `ExPTY` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:expty, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\nDocumentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)\nand published on [HexDocs](https://hexdocs.pm). Once published, the docs can\nbe found at \u003chttps://hexdocs.pm/expty\u003e.\n\n## Acknowledgements\n\nThis project is largely based on [microsoft/node-pty](https://github.com/microsoft/node-pty). Many thanks to all developers and maintainers, without them this wouldn't be possible.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcocoa-xu%2Fexpty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcocoa-xu%2Fexpty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcocoa-xu%2Fexpty/lists"}