Giter VIP home page Giter VIP logo

terminal-tab's Introduction

Terminal Tab

Open a terminal tab programatically.

Install

npm install terminal-tab -g

Getting started

const terminalTab = require('terminal-tab')

terminalTab.open(`echo "my command"; sleep 2 && exit`)

Options

Child process command options:

const options = {
  cwd: null,
  env: null,
  encoding: 'utf8'
}

terminalTab.open(`echo "my command"`, options)

Event callbacks

terminalTab.open(`echo "my command"`, options, {
  onStdout: (stdout) => {},
  onStderr: (stderr) => {},
  onError: (error) => {},
  onExit: (code, signal) => {
    console.log('exit:', code, signal)
    process.exit(0)
  }
})

Alternatively:

terminalTab.open(`echo "my command"`, options, (stdout) => {})

Without options:

terminalTab.open(`echo "my command"`, (stdout) => {})

CLI

terminal_tab 'echo hello'

Piping

echo 'echo hello' | terminal_tab

License

MIT

terminal-tab's People

Contributors

kfirp-rewire avatar miguelmota avatar obetame avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

terminal-tab's Issues

When the second terminal is open, the commands are still sent to the first

I am trying to use this library and its open() method, so my goal is to open N terminals and run different command on them, however when I am doing something like the following:

const terminalTab = require('terminal-tab');
terminalTab.open('echo hello; echo hello2');
terminalTab.open('echo hello3; echo hello4');

Both of the terminal windows are being open successfully, however on the first one I get all the 4 echos, the second terminal is just empty.

Is this library (method) suppose to work with more than one terminal?

Looking for Windows and Linux-Ubuntu solution

Thanks for your excellent code.

I'm building a cross platform app and I would like to open the terminal cross all platform(cmd for Win, bash for Linux). I check your code it seems implemented by AppleScript?

But, is there any methodology to open cmd or bash GUI window through normal NodeJS? How can I implemented it? Any Ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.