All Projects → microsoft → Node Pty

microsoft / Node Pty

Licence: other
Fork pseudoterminals in Node.JS

Programming Languages

typescript
32286 projects

Labels

Projects that are alternatives of or similar to Node Pty

Awesome Macos Command Line
Use your macOS terminal shell to do awesome things.
Stars: ✭ 25,622 (+2998.19%)
Mutual labels:  terminal
Suplemon
🍋 Console (CLI) text editor with multi cursor support. Suplemon replicates Sublime Text like functionality in the terminal. Try it out, give feedback, fork it!
Stars: ✭ 734 (-11.25%)
Mutual labels:  terminal
Pixterm
Draw images in your ANSI terminal with true color
Stars: ✭ 782 (-5.44%)
Mutual labels:  terminal
Papertty
PaperTTY - Python module to render a TTY or VNC on e-ink
Stars: ✭ 699 (-15.48%)
Mutual labels:  terminal
Terminator Themes
🤘 The biggest collection of Terminator themes.
Stars: ✭ 717 (-13.3%)
Mutual labels:  terminal
Imgp
📸 High-performance cli batch image resizer and rotator
Stars: ✭ 744 (-10.04%)
Mutual labels:  terminal
Cheat.sh
the only cheat sheet you need
Stars: ✭ 27,798 (+3261.31%)
Mutual labels:  terminal
Pyterminfo
A terminfo-to-python cross compiler
Stars: ✭ 5 (-99.4%)
Mutual labels:  terminal
Unicodeplots.jl
Unicode-based scientific plotting for working in the terminal
Stars: ✭ 724 (-12.45%)
Mutual labels:  terminal
Chafa
📺🗿 Terminal graphics for the 21st century.
Stars: ✭ 774 (-6.41%)
Mutual labels:  terminal
Ueberzug
ueberzug is a command line util which allows to display images in combination with X11
Stars: ✭ 711 (-14.03%)
Mutual labels:  terminal
Colored
(Rust) Coloring terminal so simple you already know how to do it !
Stars: ✭ 715 (-13.54%)
Mutual labels:  terminal
Termdown
Countdown timer and stopwatch in your terminal
Stars: ✭ 749 (-9.43%)
Mutual labels:  terminal
Bat
A cat(1) clone with wings.
Stars: ✭ 30,833 (+3628.3%)
Mutual labels:  terminal
Opscloud
运维管理平台(阿里云),自动同步阿里云配置信息,堡垒机(容器),批量运维,Kubernetes,Zabbix管理等功能
Stars: ✭ 788 (-4.72%)
Mutual labels:  terminal
Rich
Rich is a Python library for rich text and beautiful formatting in the terminal.
Stars: ✭ 31,664 (+3728.78%)
Mutual labels:  terminal
Qr Filetransfer
Transfer files over WiFi between your computer and your smartphone from the terminal
Stars: ✭ 738 (-10.76%)
Mutual labels:  terminal
Nexphisher
Advanced Phishing tool for Linux & Termux
Stars: ✭ 822 (-0.6%)
Mutual labels:  terminal
Ergonomica
🖥️ a cross-platform modern shell.
Stars: ✭ 815 (-1.45%)
Mutual labels:  terminal
Wezterm
A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
Stars: ✭ 770 (-6.89%)
Mutual labels:  terminal

node-pty

Build Status

forkpty(3) bindings for node.js. This allows you to fork processes with pseudoterminal file descriptors. It returns a terminal object which allows reads and writes.

This is useful for:

  • Writing a terminal emulator (eg. via xterm.js).
  • Getting certain programs to think you're a terminal, such as when you need a program to send you control sequences.

node-pty supports Linux, macOS and Windows. Windows support is possible by utilizing the Windows conpty API on Windows 1809+ and the winpty library in older version.

API

The full API for node-pty is contained within the TypeScript declaration file, use the branch/tag picker in GitHub (w) to navigate to the correct version of the API.

Example Usage

var os = require('os');
var pty = require('node-pty');

var shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';

var ptyProcess = pty.spawn(shell, [], {
  name: 'xterm-color',
  cols: 80,
  rows: 30,
  cwd: process.env.HOME,
  env: process.env
});

ptyProcess.on('data', function(data) {
  process.stdout.write(data);
});

ptyProcess.write('ls\r');
ptyProcess.resize(100, 40);
ptyProcess.write('ls\r');

Real-world Uses

node-pty powers many different terminal emulators, including:

  • Microsoft Visual Studio Code
  • Hyper
  • Upterm
  • Script Runner for Atom.
  • Theia
  • FreeMAN file manager
  • terminus - An Atom plugin for providing terminals inside your Atom workspace.
  • x-terminal - Also an Atom plugin that provides terminals inside your Atom workspace.
  • Termination - Also an Atom plugin that provides terminals inside your Atom workspace.
  • atom-xterm - Also an Atom plugin that provides terminals inside your Atom workspace.
  • electerm Terminal/SSH/SFTP client(Linux, macOS, Windows).
  • Extraterm
  • Wetty Browser based Terminal over HTTP and HTTPS
  • nomad
  • DockerStacks Local LAMP/LEMP stack using Docker
  • TeleType: cli tool that allows you to share your terminal online conveniently. Show off mad cli-fu, help a colleague, teach, or troubleshoot.
  • mesos-term: A web terminal for Apache Mesos. It allows to execute commands within containers.
  • Commas: A hackable terminal and command runner.
  • ENiGMA½ BBS Software: A modern BBS software with a nostalgic flair!

Do you use node-pty in your application as well? Please open a Pull Request to include it here. We would love to have it in our list.

Building

# Install dependencies and build C++
npm install
# Compile TypeScript -> JavaScript
npm run build

Dependencies

Node.JS 12+ or Electron 8+ is required to use node-pty.

Linux (apt)

sudo apt install -y make python build-essential

macOS

Xcode is needed to compile the sources, this can be installed from the App Store.

Windows

npm install requires some tools to be present in the system like Python and C++ compiler. Windows users can easily install them by running the following command in PowerShell as administrator. For more information see https://github.com/felixrieseberg/windows-build-tools:

npm install --global --production windows-build-tools

The following are also needed:

  • Windows SDK - only the "Desktop C++ Apps" components are needed to be installed

Debugging

The wiki contains instructions for debugging node-pty.

Security

All processes launched from node-pty will launch at the same permission level of the parent process. Take care particularly when using node-pty inside a server that's accessible on the internet. We recommend launching the pty inside a container to protect your host machine.

Thread Safety

Note that node-pty is not thread safe so running it across multiple worker threads in node.js could cause issues.

Flow Control

Automatic flow control can be enabled by either providing handleFlowControl = true in the constructor options or setting it later on:

const PAUSE = '\x13';   // XOFF
const RESUME = '\x11';  // XON

const ptyProcess = pty.spawn(shell, [], {handleFlowControl: true});

// flow control in action
ptyProcess.write(PAUSE);  // pty will block and pause the child program
...
ptyProcess.write(RESUME); // pty will enter flow mode and resume the child program

// temporarily disable/re-enable flow control
ptyProcess.handleFlowControl = false;
...
ptyProcess.handleFlowControl = true;

By default PAUSE and RESUME are XON/XOFF control codes (as shown above). To avoid conflicts in environments that use these control codes for different purposes the messages can be customized as flowControlPause: string and flowControlResume: string in the constructor options. PAUSE and RESUME are not passed to the underlying pseudoterminal if flow control is enabled.

Troubleshooting

Powershell gives error 8009001d

Internal Windows PowerShell error. Loading managed Windows PowerShell failed with error 8009001d.

This happens when PowerShell is launched with no SystemRoot environment variable present.

ConnectNamedPipe failed: Windows error 232

This error can occur due to anti-virus software intercepting winpty from creating a pty. To workaround this you can exclude this file from your anti-virus scanning node-pty\build\Release\winpty-agent.exe

pty.js

This project is forked from chjj/pty.js with the primary goals being to provide better support for later Node.JS versions and Windows.

License

Copyright (c) 2012-2015, Christopher Jeffrey (MIT License).
Copyright (c) 2016, Daniel Imms (MIT License).
Copyright (c) 2018, Microsoft Corporation (MIT License).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].