Skip to content

Commit

Permalink
v2.0: Properly kill commands and tweak UI (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell authored Aug 3, 2020
1 parent 64c1dbe commit 45ec49d
Show file tree
Hide file tree
Showing 18 changed files with 15,409 additions and 919 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
25 changes: 20 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,43 @@
module.exports = {
root: true,
extends: ["eslint:recommended"],
plugins: ["@typescript-eslint"],
env: {
es6: true,
es2020: true,
node: true,
},
parser: "@typescript-eslint/parser",
rules: {
...require("@typescript-eslint/eslint-plugin").configs["eslint-recommended"]
.overrides[0].rules,
...require("@typescript-eslint/eslint-plugin").configs.recommended.rules,
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-var-requires": "off",
"arrow-body-style": "error",
curly: "error",
"dot-notation": "error",
"no-fallthrough": "off",
"no-shadow": "error",
"no-var": "error",
"prefer-const": "error",
"object-shorthand": "error",
"one-var": ["error", "never"],
"prefer-arrow-callback": "error",
"prefer-destructuring": ["error", { array: false, object: true }],
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
eqeqeq: "error",
strict: "error",
},
overrides: [
{
files: "run-pty.js",
parserOptions: {
project: "./tsconfig.json",
},
rules: {
...require("@typescript-eslint/eslint-plugin").configs[
"recommended-requiring-type-checking"
].rules,
},
},
{
files: "*.test.js",
extends: ["plugin:jest/recommended"],
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.cache
dist
node_modules
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.cache
.vscode
dist
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.PHONY: watch
watch:
echo "Watching..."
cat
112 changes: 99 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,105 @@
# run-pty

In `bash` you can use `fg`, `bg`, `jobs` and <kbd>ctrl+z</kbd> to run several commands at the same time in the same terminal. But it’s not very user friendly.
`run-pty` is a command line tool that lets you run several commands _concurrently_ and _interactively._ Show output for one command at a time. Kill all at once. Nothing more, nothing less.

`run-pty` is a command line tool that lets you run several commands concurrently. Show output for one command at a time. Kill all at once. Nothing more, nothing less.
It’s like [concurrently] but the command outputs aren’t mixed, and you can restart commands individually and interact with them. I bet you can do the same with [tmux] if you – and your team mates – feel like installing and learning it. In `bash` you can use `command1 & command2` together with `fg`, `bg`, `jobs` and <kbd>ctrl+z</kbd> to achieve a similar result, but run-pty tries to be easier to use, and cross-platform.

<kbd>ctrl+z</kbd> shows the _dashboard,_ which gives you an overview of all your running commands and lets you switch between them.

<kbd>ctrl+c</kbd> exits current/all commands.
<kbd>ctrl+c</kbd> kills commands.

A use case is running several watchers. Maybe one or two for frontend (webpack, Parcel, Sass), and one for backend (nodemon, TypeScript, or even some watcher for another programming language).
A use case is running several watchers. Maybe one or two for frontend (webpack, Parcel, Sass), and one for backend (nodemon, or even some watcher for another programming language).

## Example

```json
{
"scripts": {
"watch:frontend": "webpack-dev-server",
"watch:backend": "nodemon server/index.ts",
"watch:all": "run-pty % npm run watch:frontend % npm run watch:backend"
"start": "run-pty % npm run frontend % npm run backend",
"frontend": "parcel watch index.html",
"backend": "nodemon server.js"
}
}
```

```
1 🟢 pid 78147 npm run 'watch:frontend'
2 🔴 exit 1 npm run 'watch:backend'
$ npm start
> @ start /Users/lydell/src/run-pty/demo
> run-pty % npm run frontend % npm run backend
```

➡️

```
[1] 🟢 pid 11084 npm run frontend
[2] 🟢 pid 11085 npm run backend
[1-2] focus command
[ctrl+c] kill all
```

➡️ <kbd>1</kbd> ️️➡️

```
🟢 npm run frontend
> @ frontend /Users/lydell/src/run-pty/demo
> parcel watch index.html --log-level 4
[9:51:27 AM]: Building...
[9:51:27 AM]: Building index.html...
[9:51:27 AM]: Built index.html...
[9:51:27 AM]: Producing bundles...
[9:51:27 AM]: Packaging...
[9:51:27 AM]: ✨ Built in 67ms.
[ctrl+c] kill
[ctrl+z] dashboard
```

➡️ <kbd>ctrl+c</kbd> ➡️

1-2 switch command
ctrl+c exit current/all
ctrl+z this dashboard
```
🟢 npm run frontend
> @ frontend /Users/lydell/src/run-pty/demo
> parcel watch index.html --log-level 4
[9:51:27 AM]: Building...
[9:51:27 AM]: Building index.html...
[9:51:27 AM]: Built index.html...
[9:51:27 AM]: Producing bundles...
[9:51:27 AM]: Packaging...
[9:51:27 AM]: ✨ Built in 67ms.
⚪ npm run frontend
exit 0
[enter] restart
[ctrl+c] kill all
[ctrl+z] dashboard
```

➡️ <kbd>ctrl+z</kbd> ➡️

```
[1] ⚪ exit 0 npm run frontend
[2] 🟢 pid 11085 npm run backend
[1-2] focus command
[ctrl+c] kill all
```

➡️ <kbd>ctrl+c</kbd> ➡️

```
[1] ⚪ exit 0 npm run frontend
[2] ⚪ exit 0 npm run backend
$ ▊
```

## Installation
Expand All @@ -40,9 +113,22 @@ ctrl+z this dashboard
- [microsoft/node-pty] does all the heavy lifting of running the commands.
- [apiel/run-screen] was the inspiration for this tool.

## iTerm2 flicker

[iTerm2] has a bug where the window flickers when clearing the screen without GPU rendering: <https://gitlab.com/gnachman/iterm2/-/issues/7677>

GPU rendering seems to be enabled by default, as long as your computer is connected to power.

You can enable GPU rendering always by toggling “Preferences > General > Magic > GPU Rendering + Advanced GPU Settings… > Disable GPU rendering when disconnected from power.”

There might still be occasional flicker. Hopefully the iTerm2 developers will improve this some time. It does not happen in the standard Terminal app.

## License

[MIT](LICENSE).

[microsoft/node-pty]: https://github.com/microsoft/node-pty
[apiel/run-screen]: https://github.com/apiel/run-screen
[concurrently]: https://github.com/kimmobrunfeldt/concurrently
[iterm2]: https://www.iterm2.com/
[microsoft/node-pty]: https://github.com/microsoft/node-pty
[tmux]: https://github.com/tmux/tmux
Empty file added demo/index.html
Empty file.
Loading

0 comments on commit 45ec49d

Please sign in to comment.