Skip to content

Instantly share code, notes, and snippets.

@jerch
Created August 28, 2018 00:00
Show Gist options
  • Save jerch/a592dff6a57770fd59044400d83c5f12 to your computer and use it in GitHub Desktop.
Save jerch/a592dff6a57770fd59044400d83c5f12 to your computer and use it in GitHub Desktop.
var os = require('os');
var pty = require('./lib/index');
var shell = os.platform() === 'win32'
? 'powershell.exe'
: 'bash';
process.on('exit', function(c) {
console.log('exit ' + c)
});
process.on('SIGINT', function(c) {
console.log('sigint ' + c);
process.exit();
});
var ptyProcess = pty.spawn(shell, [], {
name: 'xterm-color',
cols: 80,
rows: 30,
cwd: process.env.HOME,
env: process.env
});
ptyProcess.on('data', function (data) {
console.log(data);
});
ptyProcess.write('ls\r');
setTimeout(function() {
ptyProcess.kill();
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment