How do you copy and paste in the terminal?
| Copy | Paste | Plain Ctrl+C | |
|---|---|---|---|
| Windows Terminal | Ctrl+C or Ctrl+Shift+C | Ctrl+V or Ctrl+Shift+V | copies your selection, or interrupts when there is none |
| Command Prompt (classic console) | Select, then Enter | Right-click | interrupts |
| Terminal.app and iTerm2 | Cmd+C | Cmd+V | interrupts |
| GNOME Terminal and Konsole | Ctrl+Shift+C | Ctrl+Shift+V | interrupts |
| PuTTY | Select (copies on release) | Right-click or Shift+Insert | interrupts |
| Web terminal in a browser | Select, then Ctrl+Insert | Ctrl+V or Shift+Insert | interrupts |
Each row comes from the vendor’s own documentation: Windows Terminal actions, the Windows console, Terminal keyboard shortcuts, GNOME Terminal shortcuts and the Konsole command reference, the PuTTY manual and Plesk’s web terminal docs.
The clipboard holds one copy at a time, so a long command you copied yesterday is gone once you copy anything else. A clipboard manager like Relic keeps every command and snippet you copy, so you can search for it later on Windows, Mac and Linux.
Why does Ctrl+C cancel a command instead of copying?
Long before Windows borrowed Ctrl+C for copying, terminals used it as a control character. Pressing it sends the interrupt signal, SIGINT, to the program in the foreground, which tells it to stop. That is how you kill a command that is hanging or break out of a script printing forever. The behaviour is in the POSIX terminal interface, and the GNU C Library puts it plainly: “Typically, the INTR character is C-c”. Because that meaning came first, terminals could not make Ctrl+C copy without breaking the cancel everyone relies on.
How do you copy and paste in Windows Terminal?
Windows Terminal hosts PowerShell, Command Prompt and WSL. Its actions reference lists four default bindings for copy (ctrl+c, ctrl+shift+c, ctrl+insert and enter) and three for paste (ctrl+v, ctrl+shift+v and shift+insert). So plain Ctrl+C is a copy binding out of the box. What it does depends on your selection: “This copies the selected terminal content to your clipboard. If no selection exists, the key chord is sent directly to the terminal.” There is no setting to switch on. Select some text and Ctrl+C copies it. Select nothing and Ctrl+C interrupts.
There is also a copyOnSelectsetting, off by default, that copies text the instant you finish highlighting it, with no key press. Turn it on under Settings, Interaction if you like the Linux habit where selecting is copying. Because these are settings, someone else’s machine may not match yours, so when in doubt use the explicit CtrlShiftC and CtrlShiftV.
The classic Command Prompt window
The old black cmd.exe window (technically the console host, conhost) plays by older rules than Windows Terminal, and plenty of machines still open it. Copying there is a mouse operation built on QuickEdit Mode, which is on by default in current Windows.
- Select: click and drag the mouse across the text to highlight it.
- Copy: press Enter, or right-click the selection.
- Paste: right-click anywhere in the window with nothing selected.
If QuickEdit is off (right-click the title bar, then Properties, then the Options tab to check), you have to pick Mark from the title-bar menu before you can drag-select. With QuickEdit on, you skip that step.
Block (rectangular) selection
A normal drag grabs whole lines. Hold Alt while you drag and you get a rectangular block instead, which is how you pull one column out of aligned output. It works in Windows Terminal too.
The Edit menu, for when there is no mouse
Both consoles keep the old keyboard-driven Edit menu. Press AltSpace to open the window menu, then E for Edit, and you get Mark, Copy and Paste as menu items. Mark drops you into a keyboard selection mode: the arrow keys move the cursor, Shift plus arrows extends the selection, and Enter copies. It is slower than dragging, and it is what you have over a bare Remote Desktop session.
Pasting into a console, carefully
- Multi-line paste. The console treats each line break as if you pressed Enter, so a clipboard holding five lines runs five commands. Windows Terminal warns you first. The classic console does not, so be sure that is what you meant.
- Smart quotes. Text copied out of a document or a chat app can carry curly quotation marks the shell does not recognise. If a pasted command fails with a quoting error, retype the quotes by hand.
Output that scrolled off the top
Selecting with the mouse only reaches what is still in the scrollback buffer, and a long build log runs past it. That is the strongest reason to pipe to clip rather than drag-select: piping captures the whole output whatever scrolled by. If you would rather scroll and select, the buffer height is under Properties, then the Layout tab, where a taller screen buffer keeps more lines around to copy.
Get a command’s output onto the clipboard
Selecting output with the mouse is fine for one line and miserable for fifty. Every platform has a command that does it properly. On Windows, clip takes a pipe or a file:
PowerShell has a pair of cmdlets instead. Set-Clipboard takes a value or a pipeline, and Get-Clipboard reads it back, so you can capture the clipboard into a variable and keep working:
Set-Clipboard instead.Use the clipboard when the next step is a paste into a browser or a chat. Redirect to a file when the next step is another command, and remember >> appends where > overwrites:
Piping a whole build log into the clipboard and then losing it to the next copy is a bad afternoon.
macOS: Terminal.app and iTerm2
The Mac is the easy one. Apple’s shortcut listgives Command-C for copy and Command-V for paste, and says Control-C “sends a signal that causes most commands to terminate”. Copy lives on the Command key and cancel lives on the Control key, so the Mac never had to move its copy shortcut.
iTerm2 adds two things worth turning on. Its preferences have Copy to clipboard on selection, which copies text the moment you select it. And with Save copy/paste and command history to disk on, it keeps the last 20 values, which you open with Edit > Open Paste History.
On the command line, pbcopy and pbpaste are the macOS equivalents of clip:
How do you copy and paste in a Linux terminal?
GNOME Terminal, Konsole and the terminal inside most editors use Ctrl+Shift+C and Ctrl+Shift+V. Linux also has a second clipboard that the others do not: the primary selection. Highlight text and it is copied there with no shortcut, and you paste it with a middle-click. The freedesktop clipboard specification says to “use PRIMARY for the currently-selected text” and that the middle mouse button “should paste PRIMARY, never CLIPBOARD”. It is separate from the Ctrl+Shift+C clipboard, so you can hold two things at once. This is standard on X11. On Wayland it depends on your compositor supporting the primary-selection protocol, so it is there on most desktops and missing on a few.
For scripts, the tool depends on your session:
tmux: copy mode
Inside tmux, copy and paste run through tmux rather than through the terminal. You enter copy mode with the prefix key, Ctrl+B by default, then [. Move around, select, and copy into tmux’s own buffer. Paste it back with the prefix key then ]. In vi mode, Space starts a selection and Enter copies it. All of that is in the tmux manual.
By default that buffer stays inside tmux. To push copied text to the system clipboard as well, pipe the selection through a clipboard tool in ~/.tmux.conf:
Swap pbcopy for xclip -selection clipboard on X11 or wl-copy on Wayland.
Vim and Neovim
Vim does not copy and paste so much as yank and put. Yank a line with yy, yank a visual selection with y, put it back with p. That all happens in Vim’s own registers. To reach the clipboard your whole machine can see, use the plus register:
Vim’s own documentationsays yanking to the star or plus registers “is possible only when the +clipboard or +clipboard_provider features are included”. Check yours with vim --version and look for +clipboard. If it says -clipboard, install a build of Vim that includes clipboard support.
The auto-indent trap
Pasting many lines into Vim in insert mode often produces a staircase, because Vim indents each new line on top of indentation your text already has. Run :set paste first, paste, then :set nopaste. Vim’s options documentation says the autoindent option is reset when paste is set, which is exactly the fix. In Neovim you can skip all of it: Neovim’s deprecated list calls the paste option obsolete, because bracketed paste already handles it.
Copy and paste over SSH
When you SSH into a remote server, the copying still happens in your localterminal. Pasting into the remote shell just works, because your terminal types the clipboard’s characters into the session. Copying out works for anything on screen: you select it and your terminal copies it locally. The ssh manual documents X11, agent, port and TUN forwarding, and no clipboard forwarding, so nothing carries a clipboard between the two machines on its own. The one exception is X11 forwarding: with ssh -X, remote X programs run against your local X server and can reach your X selections, which is worth knowing before you enable it on a host you do not trust.
One thing to watch: pasting a long or multi-line command over a slow connection can behave oddly, because the characters arrive slightly apart and the remote shell may act on a half-typed line. Bracketed paste, which most modern shells support, wraps the pasted block so the shell treats it as one chunk. If you paste a command and only part of it runs, that is usually the cause.
Copying a file or long output off a server
Running pbcopy or xclip on the server puts text on the server’s clipboard, which does you no good. The answer is an escape code called OSC 52. A program on the server prints it, and your local terminal reads it and sets your local clipboard. Windows Terminal supports it for copying. iTerm2 needs Applications in terminal may access clipboard turned on in its preferences. Termius added it in version 9.31.4, according to its changelog. With nothing installed on the server, this one-liner sends a file to your local clipboard:
Inside tmux, the sequence only gets through with set -g set-clipboard on in your config, going by the tmux manual. Neovim uses OSC 52 by itself when it finds no other clipboard tool, which is the usual case on a server, though its docs say tmux can stop it detecting support. For big files, scp is still simpler.
PuTTY, Termius and Tabby
PuTTY has no copy shortcut at all. The PuTTY manualsays you drag to select and “the text is automatically copied to the clipboard” when you let go. Right-click pastes, and so does ShiftInsert. Ctrl+C goes to the server as an interrupt, so it never copies. Hold Alt while you drag to select a rectangular block.
Termius keeps its copy and paste keys under Settings, Shortcuts, and you can rebind them there. On a phone, long-press in the terminal and tap Paste. Tabby(the app that used to be called Terminus) has a copy-on-select option and can be set to paste on right-click. Its hotkeys live in Settings too, so if Ctrl+Shift+C does nothing, check what’s bound there.
Web terminals in Plesk, cPanel and other hosting panels
A terminal inside a browser tab plays by the browser’s rules. The first time you paste, the browser may ask to let the site see your clipboard. Allow it, or turn on Clipboard in the site settings behind the icon at the left of the address bar. The Plesk docs say you can only paste into its SSH terminal with a keyboard shortcut, and to try Ctrl+Insert or Shift+Insert if Ctrl+V fails. Ctrl+Shift+V is worth a try as well, since browsers treat it as a plain-text paste.
Copying out is where these terminals trip people up. Ctrl+C interrupts, as in any shell, and Ctrl+Shift+C opens the developer tools in Chrome, Edge and Firefox. Select the text and press CtrlInsert instead.
Keep the commands you copy
The other half of terminal copy and paste is finding a command again next week. Relic keeps what you copy on your machines, and the desktop app ships a relic command so you never have to leave the shell. On Windows the installer puts it on your PATH. On a Mac and on Linux the command ships with the app and you link it once.
relic status says whether the app is there and what the local vault holds. Search prints a uid per hit, and -q prints only the uids so you can pipe them into the next command. relic get --raw prints just the text, and relic export <uid> ./file.png writes an image or a file out of the vault. It reads the same local vault the app uses, with no account, no passphrase and no network of its own. Add --json when a script is reading the output. The relic command has the full list.
Copying in a Windows console, at a glance
- Classic cmd: drag to select, Enter or right-click to copy, right-click to paste.
- There, CtrlC copies only with a selection. With nothing selected it cancels the command.
- Windows Terminal: CtrlShiftC and CtrlShiftV always mean copy and paste.
- Pipe to
clip, or useSet-Clipboard, to copy a whole command’s output. - Hold Alt while dragging for a rectangular block selection.
A few habits that save grief
- Try Shift first. When a terminal will not copy, Ctrl+Shift+C is the right guess almost everywhere. Windows Terminal accepts it too, so it is the one chord that works on Windows and Linux both.
- Re-read what you paste. Commands copied from a web page can carry hidden characters or a trailing newline that runs the command before you have read it. Paste into a plain editor first when the source is untrusted.
- Copy file paths cleanly. Getting a full path onto the clipboard without retyping it is its own small skill. We cover the shortcuts in how to copy a file path.
- Know what you are copying. Tokens and IDs you move around all day, like a JWT or a Base64 string, are easy to mangle with one stray character, so a clean copy matters more than usual.
Sources
- Windows Terminal actions, Microsoft Learn
- Windows Terminal interaction settings, Microsoft Learn
- Changes to the Windows Console, Microsoft Learn
- clip command reference, Microsoft Learn (2023)
- Keyboard shortcuts in Terminal on Mac, Apple Support
- GNOME Terminal keyboard shortcuts, GNOME Help
- Konsole command reference, KDE Documentation
- PuTTY user manual, chapter 3: using PuTTY, PuTTY
- Accessing the command line from the Plesk interface, Plesk Documentation
- Termius changelog, Termius
- tmux manual page, man7.org
- Neovim providers: clipboard, Neovim
Frequently asked questions
Your next step
Try the two lines that pay off fastest in your own shell: pipe something into clip, pbcopy or wl-copy, and then run relic status if you have the app. The relic command and Relic for AI agents are both readable without an account, and the developer page has the install lines for each platform. For copy and paste outside a shell, the general guide to copying and pasting covers the basics.