Keys, mouse and clipboard
In the terminal, the keyboard and the mouse belong to the program running there. The application keeps the keys with ⌘, and the mouse selects text unless the program has asked for it.
Which keys are whose
- Keys go to the program: the function keys, Tab, Esc, the arrows and everything typed — full-screen programs live on them.
- Keys with ⌘ are the application’s, and do what they mean in the terminal: the tabs, the line under the panes, the viewer, the list below. A ⌘ key that means nothing here is dropped, never passed on as a stray character.
- The menus and the help are F9 and F1 with ⌘ held, since the bare keys are the program’s. ⌘K lists everything you can do from here.
- A key you bind in the terminal yourself, without ⌘, is taken from the program — see key bindings.
The Option key
What ⌥ sends is set for each side of the keyboard: Left Option key and Right Option key.
| Set to | ⌥ with a key |
|---|---|
| normal, as shipped | Types what your keyboard layout puts there — ©, ∑, or an accent for the next letter |
| meta | Sends the program Esc and then the key’s own character — what the shells’ word motion, fzf’s ⌥C and a program’s Alt bindings expect |
- Setting one side to meta keeps the other for typing characters.
- ⌥ with a key that types nothing — an arrow, a function key — is sent with Alt held, from either side.
- Which side is held is known from the moment ⌥ goes down. One already held when the window came to the front counts as meta only where both sides are.
- On the command line, ⌥↑ and ⌥↓ step through the shell’s own history on a normal side — see The command line.
Control keys
- ⌃ with a letter sends its control character — ⌃C, ⌃D, ⌃R mean what the
shell and the program make of them. So does ⌃ with
[,\,],-or/. - ⌃2 to ⌃8 send the rest: NUL, Esc, FS, GS, RS, US and DEL.
- ⌃Space never arrives while macOS uses it to switch input sources, as it does to begin with. Turn that shortcut off in System Settings › Keyboard › Keyboard Shortcuts › Input Sources, and it reaches the program.
What a program can ask for
A program can ask the terminal for more than plain keys, and gets it:
- The keyboard protocol
- Programs such as fish, nvim and Claude Code turn it on. Every key with a modifier is then sent as itself, so ⇧Enter, ⌃Enter and ⌃I arrive apart from Enter and Tab, and Esc alone is never taken for the start of another key.
- Focus
- A program that asks — nvim does, to notice files changed outside it — is told when the terminal gains or loses the keyboard: shown or put away, the keyboard moving between a terminal beside a pane and the pane, the command line taking it, and the window itself. A menu or dialog over the terminal leaves it the keyboard.
The mouse
The same in the full terminal and beside a pane.
| Do | At a prompt, or in a program that has not asked for the mouse | In a program that has — vim, htop, tmux |
|---|---|---|
| Drag | Selects, scrolling back as you drag past the top or the bottom | The program’s |
| Double-click, triple-click | Selects a word, a line — drag on to take more | The program’s |
| ⌥-drag | Selects a block of columns | The program’s |
| ⇧ with any of these | ⇧-click extends the selection | Selects, as if the program had not asked |
| Click in the command you are typing | Moves the cursor there | The program’s |
| The wheel | Scrolls back through what has scrolled off the top | The program’s |
| The middle and right buttons | Nothing | The program’s |
| The pointer passing over | Nothing | The program’s, if it asked for every move |
- Typing brings the view back to the bottom and drops the selection.
- ⌘-click on a file name in a command’s output goes to it — see files in the output.
- A word is letters, digits and
/ - + \ ~ _ ., so a double-click takes a path or an option whole. A line is every row it wrapped onto. - A prompt theme’s right-hand prompt is not part of the line you type on: selecting the line leaves it out, and a click past the end of the command goes to the end of the command.
- A click in the command moves the cursor with the shell’s own arrow keys, and needs the shell’s integration to know where the command begins.
less,manand other programs that fill the screen without asking for the mouse have nothing to scroll back to, so the wheel sends them ↑ and ↓, a row a notch — unless Wheel scrolls in less and man is off.- Scrolled back, a program that asked for the mouse is sent nothing until you are at the bottom again.
The command line under the panes takes no mouse.
Copying and pasting
- ⌘C copies the selection. With a command highlighted, it copies everything the command printed.
- ⌘V pastes. Where the program has asked for pasted text to be marked — shells do — it is sent marked, so a line break in it waits for your Enter instead of running. Anything in the text that would end the marking early is taken out first.
- On the command line, text with a line break or a control character is refused, with a notice, where the shell has not asked for that. A terminal beside a pane pastes as the full terminal does.
- A program in the terminal is never told what is on your clipboard, and with Programs may use the clipboard off, as shipped, it cannot put anything there either. Turned on, it takes effect in the next shell started.
Every key the application answers
Each key, with what it does
| Key | Action |
|---|---|
| ⌥⌘O | Terminal |
| ⌘L | Command line |
| ⌘F5 | Insert from the panes… |
| ⌘F8 | Command history… |
| ⌘G | Move the shell to a folder… |
| ⌘F3 | Terminal's last output in the viewer |
| ⇧⌘F3 | Terminal's scrollback in the viewer |
| ⌘T | New terminal tab |
| ⌘W | Close terminal tab |
| ⇧⌘I | Name terminal tab… |
| ⇧⌘[ | Previous terminal tab |
| ⇧⌘] | Next terminal tab |
| ⇧⌘T | Terminal tabs… |
| ⌘1 | Terminal tab 1 |
| ⌘2 | Terminal tab 2 |
| ⌘3 | Terminal tab 3 |
| ⌘4 | Terminal tab 4 |
| ⌘5 | Terminal tab 5 |
| ⌘6 | Terminal tab 6 |
| ⌘7 | Terminal tab 7 |
| ⌘8 | Terminal tab 8 |
| ⌘9 | Terminal tab 9 |
| ⇧⌘Enter | Full width |
| ⌘K | Actions… |
| ⇧⌘= | Make the text larger |
| ⇧⌘- | Make the text smaller |
| ⌘0 | Text at its usual size |
And, whatever the key bindings: ⌘↑ and ⌘↓ to step through commands, ⌘C to copy and ⌘V to paste.