turbo-editors/turbo-jspublic Fork 0
v1.0.0
Commits
Clone
git clone https://git.rickub.com/turbo-editors/turbo-js.git
git clone ssh://git@rickub.com/turbo-editors/turbo-js.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

📦 Turbo JS 91999d1 · on v1.0.0 · k33g · 11h ago
use-a-terminal.md · 68 lines · 3.9 KBmarkdown
Blame HistoryOpen raw

How to run shell commands without leaving the editor

This guide shows how to open a terminal window, run and test the script you are editing in it, and get back to the file. It assumes you already have Turbo JS running with a file open.

Open a terminal

Press F8, or choose Window ▸ New terminal.

A new window opens running your shell, in the directory of the file you were editing. That is normally the directory you want: node --test and git diff both act on the directory you are looking at.

The window is called after the shell, and renames itself when a program inside it sets a title — vim, htop and ssh all do.

Run something

Type into it as you would into any terminal. The shell gets nearly every key, including the ones the editor would otherwise use: Ctrl-C interrupts, Ctrl-W deletes a word, Ctrl-R searches the history.

node main.js
node --test
node            # Node's REPL — a real terminal, so it can read your keyboard

What the editor keeps is short, and deliberate — it is the way back out:

Key Effect, even with a terminal in front
F8 Open another terminal
F6 Move to the next window
F10 Open the menu bar
F2 F3 F4 Save, Open, New
Alt-1Alt-9 Bring that window forward
Alt-X Leave the editor

Read back through what scrolled off

Shift-PgUp and Shift-PgDn walk the history a screenful at a time; the mouse wheel moves three lines. Two thousand lines are kept.

Typing anything brings you straight back to the live screen, so you never have to scroll back down before running the next command.

Work with the file and the shell side by side

A terminal is an ordinary window, so the window commands all apply to it:

  • Window ▸ Tile puts the file and the terminal side by side.
  • Window ▸ Maximise, or the [■] box at the right of its title bar, gives the terminal the whole desktop while a build runs. The box then reads [▬], and pressing it puts the window back.
  • Drag its bottom-right corner to resize it — the shell is told its new size, so less and vim reflow.

Close it

Ctrl-W is the shell's, not the editor's, so closing a terminal is done another way:

  • File ▸ Close, or
  • click the [x] box in its top-left corner.

Either ends the shell running in it. Nothing is asked first: a terminal holds a running process, not unsaved work, and closing the window is how you say you have finished with it. Leaving the editor closes every terminal at once.

Variants

  • You want a different shell. The shell is taken from $SHELL, falling back to /bin/sh; on Windows from %COMSPEC%, falling back to cmd.exe. Start the editor with SHELL=/bin/zsh turbo-js to change it for that run.
  • No file is open. The terminal starts in the directory the editor was started from.
  • You run the same command every time. Put it in the project's tools file instead, and it becomes a line of the JavaScript menu — with a terminal window as its output when it needs the keyboard. See How to run JavaScript commands from the editor.
  • You are on Windows. Terminal windows run in a pseudo-console (ConPTY), which needs Windows 10 version 1809 or later, and the shell is %COMSPEC% — cmd.exe. This path has been built and vetted but not yet run by the authors, who work on Linux and macOS. The first time you use it, try the five things it has to get right — F8, type dir, resize the window, run a menu command that says output = "terminal", and interrupt a long one with Ctrl-C — and report whatever did not behave.

See also

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# How to run shell commands without leaving the editor

This guide shows how to open a terminal window, run and test the script you are editing in it, and get back to the file. It assumes you already have Turbo JS running with a file open.

## Open a terminal

Press `F8`, or choose **Window ▸ New terminal**.

A new window opens running your shell, in the directory of the file you were editing. That is normally the directory you want: `node --test` and `git diff` both act on the directory you are looking at.

The window is called after the shell, and renames itself when a program inside it sets a title — `vim`, `htop` and `ssh` all do.

## Run something

Type into it as you would into any terminal. The shell gets nearly every key, including the ones the editor would otherwise use: `Ctrl-C` interrupts, `Ctrl-W` deletes a word, `Ctrl-R` searches the history.

```bash
node main.js
node --test
node            # Node's REPL — a real terminal, so it can read your keyboard
```

What the editor keeps is short, and deliberate — it is the way back out:

| Key | Effect, even with a terminal in front |
| --- | --- |
| `F8` | Open another terminal |
| `F6` | Move to the next window |
| `F10` | Open the menu bar |
| `F2` `F3` `F4` | Save, Open, New |
| `Alt-1``Alt-9` | Bring that window forward |
| `Alt-X` | Leave the editor |

## Read back through what scrolled off

`Shift-PgUp` and `Shift-PgDn` walk the history a screenful at a time; the mouse wheel moves three lines. Two thousand lines are kept.

Typing anything brings you straight back to the live screen, so you never have to scroll back down before running the next command.

## Work with the file and the shell side by side

A terminal is an ordinary window, so the window commands all apply to it:

- **Window ▸ Tile** puts the file and the terminal side by side.
- **Window ▸ Maximise**, or the `[■]` box at the right of its title bar, gives the terminal the whole desktop while a build runs. The box then reads `[▬]`, and pressing it puts the window back.
- Drag its bottom-right corner to resize it — the shell is told its new size, so `less` and `vim` reflow.

## Close it

`Ctrl-W` is the shell's, not the editor's, so closing a terminal is done another way:

- **File ▸ Close**, or
- click the `[x]` box in its top-left corner.

Either ends the shell running in it. Nothing is asked first: a terminal holds a running process, not unsaved work, and closing the window is how you say you have finished with it. Leaving the editor closes every terminal at once.

## Variants

- **You want a different shell.** The shell is taken from `$SHELL`, falling back to `/bin/sh`; on Windows from `%COMSPEC%`, falling back to `cmd.exe`. Start the editor with `SHELL=/bin/zsh turbo-js` to change it for that run.
- **No file is open.** The terminal starts in the directory the editor was started from.
- **You run the same command every time.** Put it in the project's tools file instead, and it becomes a line of the **JavaScript** menu — with a terminal window as its output when it needs the keyboard. See [How to run JavaScript commands from the editor](run-node-commands.md).
- **You are on Windows.** Terminal windows run in a pseudo-console (ConPTY), which needs Windows 10 version 1809 or later, and the shell is `%COMSPEC%` — cmd.exe. This path has been built and vetted but not yet run by the authors, who work on Linux and macOS. The first time you use it, try the five things it has to get right — `F8`, type `dir`, resize the window, run a menu command that says `output = "terminal"`, and interrupt a long one with `Ctrl-C` — and report whatever did not behave.

## See also

- Everything the terminal implements, exactly: [Terminal windows reference](../reference/terminal.md)
- Why it runs a real shell rather than capturing command output: [Terminal windows](../explanation/terminal-windows.md)
- The colours it uses: [Theme file format](../reference/themes.md)