| 📦 Turbo Rust 713ea5c k33g 12h ago | 1 | # How to run shell commands without leaving the editor |
| 2 | |
| 3 | This guide shows how to open a terminal window, build and test the code you are editing in it, and get back to the file. It assumes you already have Turbo Rust running with a file open. |
| 4 | |
| 5 | ## Open a terminal |
| 6 | |
| 7 | Press `F8`, or choose **Window ▸ New terminal**. |
| 8 | |
| 9 | A new window opens running your shell, in the directory of the file you were editing. That is normally the directory you want: `cargo build` and `git diff` both act on the package you are looking at. |
| 10 | |
| 11 | The window is called after the shell, and renames itself when a program inside it sets a title — `vim`, `htop` and `ssh` all do. |
| 12 | |
| 13 | ## Run something |
| 14 | |
| 15 | 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. |
| 16 | |
| 17 | What the editor keeps is short, and deliberate — it is the way back out: |
| 18 | |
| 19 | | Key | Effect, even with a terminal in front | |
| 20 | | --- | --- | |
| 21 | | `F8` | Open another terminal | |
| 22 | | `F6` | Move to the next window | |
| 23 | | `F10` | Open the menu bar | |
| 24 | | `F2` `F3` `F4` | Save, Open, New | |
| 25 | | `Alt-1` … `Alt-9` | Bring that window forward | |
| 26 | | `Alt-X` | Leave the editor | |
| 27 | |
| 28 | ## Read back through what scrolled off |
| 29 | |
| 30 | `Shift-PgUp` and `Shift-PgDn` walk the history a screenful at a time; the mouse wheel moves three lines. Two thousand lines are kept. |
| 31 | |
| 32 | Typing anything brings you straight back to the live screen, so you never have to scroll back down before running the next command. |
| 33 | |
| 34 | ## Work with the file and the shell side by side |
| 35 | |
| 36 | A terminal is an ordinary window, so the window commands all apply to it: |
| 37 | |
| 38 | - **Window ▸ Tile** puts the file and the terminal side by side. |
| 39 | - **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. |
| 40 | - Drag its bottom-right corner to resize it — the shell is told its new size, so `less` and `vim` reflow. |
| 41 | |
| 42 | ## Close it |
| 43 | |
| 44 | `Ctrl-W` is the shell's, not the editor's, so closing a terminal is done another way: |
| 45 | |
| 46 | - **File ▸ Close**, or |
| 47 | - click the `[x]` box in its top-left corner. |
| 48 | |
| 49 | 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. |
| 50 | |
| 51 | ## Variants |
| 52 | |
| 53 | - **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-rust` to change it for that run. |
| 54 | - **No file is open.** The terminal starts in the directory the editor was started from. |
| 55 | - **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. |
| 56 | |
| 57 | ## See also |
| 58 | |
| 59 | - Everything the terminal implements, exactly: [Terminal windows reference](../reference/terminal.md) |
| 60 | - Why it runs a real shell rather than capturing command output: [Terminal windows](../explanation/terminal-windows.md) |
| 61 | - The colours it uses: [Theme file format](../reference/themes.md) |