Relic
Get Relic free
Developer copy and paste

How to copy and paste in the terminal

Ctrl+C does not copy in a terminal. It cancels the running command. Copy moved one key over, to Ctrl+Shift+C, on most terminals. Here are the shortcuts for each terminal, the commands that put output straight on your clipboard, and the awkward corners: tmux, Vim and SSH.

Jordan Gibbs June 29, 2026 13 min readUpdated September 28, 2026

How do you copy and paste in the terminal?

CopyPastePlain Ctrl+C
Windows TerminalCtrl+C or Ctrl+Shift+CCtrl+V or Ctrl+Shift+Vcopies your selection, or interrupts when there is none
Command Prompt (classic console)Select, then EnterRight-clickinterrupts
Terminal.app and iTerm2Cmd+CCmd+Vinterrupts
GNOME Terminal and KonsoleCtrl+Shift+CCtrl+Shift+Vinterrupts
PuTTYSelect (copies on release)Right-click or Shift+Insertinterrupts
Web terminal in a browserSelect, then Ctrl+InsertCtrl+V or Shift+Insertinterrupts

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.

The rule for almost every terminal: Ctrl+Shift+C copies, Ctrl+Shift+V pastes, and plain Ctrl+C cancels. Windows Terminal is smarter about it, and a Mac uses Cmd+C and Cmd+V.

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.

The one rule that saves grief here: in the classic console, CtrlC copies only when text is already selected, which is what Microsoft’s console documentation describes. With nothing selected it sends the break signal and cancels whatever is running. Select first, then copy, or you kill your command instead of copying its output.

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:

Command Prompt
dir | clip
clip < readme.txt

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:

PowerShell
Get-Content .\id_ed25519.pub | Set-Clipboard
Set-Clipboard -Value "one line, straight to the clipboard"
$key = Get-Clipboard
One gotcha with clip: it appends a trailing newline. Paste that into a shell prompt and the newline runs the line before you have read it. When you need the value exactly, use PowerShell’s 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:

Clipboard or file
dir | clip            # to the clipboard, paste once
dir > listing.txt     # to a file, kept on disk
dir >> listing.txt    # append instead of overwriting

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:

zsh
git rev-parse HEAD | pbcopy
pbpaste > commit.txt

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:

bash
# X11
cat notes.txt | xclip -selection clipboard
xclip -selection clipboard -o > out.txt

# Wayland
cat notes.txt | wl-copy
wl-paste > out.txt

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:

~/.tmux.conf
setw -g mode-keys vi
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe "pbcopy"

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
"+y
"+p

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:

remote shell
printf '\033]52;c;%s\a' "$(base64 < notes.txt | tr -d '\n')"

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.

terminal
relic status
relic search "docker run" --limit 5
relic search "docker run" -q
relic get <uid> --raw

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 use Set-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

Frequently asked questions

Why does Ctrl+C not copy in the terminal?

Ctrl+C is the interrupt character. It sends SIGINT to the program running in the foreground, which usually stops it. That meaning predates the Windows copy shortcut, so terminals moved copy to Ctrl+Shift+C. Windows Terminal is the exception: Ctrl+C is one of its default copy bindings, and Microsoft's docs say it copies the selection when there is one and otherwise sends the key chord straight to the terminal.

How do I copy a command's output to the clipboard?

On Windows, pipe it into clip: dir | clip. In PowerShell, pipe it into Set-Clipboard, and read it back with Get-Clipboard. On a Mac, pipe into pbcopy and read back with pbpaste. On Linux, use xclip -selection clipboard on X11 or wl-copy on Wayland.

How do I paste into Vim without the formatting going wrong?

Pasting into insert mode lets Vim's auto-indent stack up on indentation your text already has. Run :set paste first, paste, then :set nopaste. Vim's docs say the autoindent option is reset when paste is set. In Neovim you do not need this at all: its own documentation calls the paste option obsolete, because bracketed paste handles it.

Can I copy and paste over an SSH session?

Yes, because the copying happens in your local terminal. You select text from the remote session, your terminal puts it on your local clipboard, and pasting sends the characters as if you typed them. The ssh manual documents no clipboard forwarding, so to copy a whole file or long output off the server, print it through the OSC 52 escape code, which terminals like Windows Terminal, iTerm2 and Termius turn into a local copy.

How do I paste into PuTTY?

Right-click anywhere in the PuTTY window, or press Shift+Insert. To copy, just select text with the mouse. The PuTTY manual says the selection is copied to the clipboard automatically when you let go, and Ctrl+C is sent to the server instead.

How do I find a command I copied earlier?

Your shell history finds commands you ran, with the up arrow or Ctrl+R in bash and zsh. Text you copied but never ran is harder, because the clipboard keeps only the last item. A clipboard manager like Relic keeps everything you copy, so you can search for it later.

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.

Written by
Jordan GibbsFounder, Relic

Jordan Gibbs is the founder of Relic, an end-to-end encrypted, permanent, searchable memory for everything you copy. He writes widely about AI, agents, and practical tooling on Medium, where he is read by tens of thousands, and builds privacy-first software. Here he covers how everyday tools like the clipboard actually work, and how to use them without handing your data to someone else.

MediumGitHubLinkedIn
Part of
Developer copy and paste
Keep reading
7 min

What is a UUID?

A UUID is a 128-bit value designed to be unique without any central authority handing it out. What they are, how the versions differ, and when to reach for one.

Read
7 min

What is a JWT token?

A JWT packs a user's identity into a signed, self-contained token. What the three parts hold, how the signature works, and what a JWT does and does not protect.

Read
8 min

What is a hash function?

A hash function squeezes any input into a short, fixed fingerprint you cannot reverse. What hashing is, how it differs from encryption, and where it shows up.

Read
developerhow-towindowsproductivity