keepcalculator

06 Numbers and Powers

iTerm2 Clipboard History: How to Use It

Card No. 06·88235 · Updated · Standard formula, shown below

iTerm2 includes a built-in clipboard history that stores every text selection and copy you make, letting you paste older items with a shortcut. You enable it in Preferences, then press Cmd+Shift+H to open the history window and search or select any saved snippet. This article explains how to turn it on, how it behaves, and how to fix common issues.

What Clipboard History Does in iTerm2

iTerm2’s clipboard history is a per-session log of everything you copy or select while using the terminal. It works alongside macOS’s system clipboard, but keeps a much longer list—macOS only remembers the most recent copy. iTerm2 stores each item as text, including command output, file paths, and partial lines you selected with the mouse.

By default, the history is saved to a file in your iTerm2 data directory, so it survives restarts. You can search it with a filter box, and you can paste any item directly into the terminal or into other apps. This is especially useful when you copy a long command, then later realize you need an earlier version of it.

Enabling Clipboard History

Clipboard history is not on by default. To turn it on:

  1. Open iTerm2 and go to iTerm2 > Preferences (or press Cmd+,).
  2. Click the General tab.
  3. Scroll to the Selection section.
  4. Check the box labeled “Save copy/paste history to disk”.
  5. Optionally, adjust the “Maximum number of entries” (default is 1000).

After enabling, iTerm2 starts recording copies and selections immediately. There is no need to restart, but you may want to test it by copying a few different strings and pressing Cmd+Shift+H.

How to View and Paste from History

Once enabled, open the clipboard history window with Cmd+Shift+H. A small panel appears listing recent items, with the most recent at the top. You can:

  • Search by typing in the filter field—matches are highlighted as you type.
  • Select an item with the arrow keys or mouse.
  • Paste the selected item by pressing Enter or double-clicking it.
  • Delete an item by selecting it and pressing Delete (or Cmd+Delete on some keyboards).

The pasted text goes into whatever app is currently focused—not necessarily the terminal. If you want to paste into the terminal, make sure the terminal window is active before pressing Enter.

What Gets Saved and What Doesn’t

iTerm2 saves two kinds of actions:

  • Copies—when you press Cmd+C or use Edit > Copy.
  • Selections—when you select text with the mouse and then either copy it or simply release the mouse (if “Copy to clipboard on selection” is enabled in Preferences).

It does not save text that is merely displayed on the screen unless you select it. It also does not save binary data or images—only plain text. Large pastes (over a certain size) may be truncated, but the default limit is generous.

Common Problems and Fixes

If clipboard history isn’t working, check these in order:

  1. Is it enabled? Go to Preferences > General and confirm “Save copy/paste history to disk” is checked.
  2. Is the history window opening? The shortcut is Cmd+Shift+H. If that doesn’t work, check your key mappings in Preferences > Keys—you may have reassigned it.
  3. Is the history empty? Make sure you copied something after enabling the feature. Old copies from before enabling are not retroactively saved.
  4. Does the panel show but nothing pastes? Click the terminal window first, then press Enter again. The panel may lose focus.
  5. Is the history file corrupted? If iTerm2 crashes or the file gets corrupted, you can delete the history file (it’s in ~/Library/Application Support/iTerm2/ and is named something like ClipboardHistory.plist). iTerm2 will recreate it on the next copy.

Clipboard History vs. System Clipboard

macOS’s own clipboard holds only the most recent item. iTerm2’s history is separate and much longer. However, they interact: when you copy in iTerm2, the text also goes to the system clipboard (unless you turn off “Copy to clipboard” in Preferences). That means you can paste iTerm2’s last copy into any app with Cmd+V, but for older items you must use iTerm2’s history window.

If you want a global clipboard manager that works across all apps, iTerm2’s history won’t help—it only records what happens inside iTerm2. For that, you’d need a separate tool like Alfred or a dedicated clipboard manager, but those are outside the scope of this article.

Privacy and Security Considerations

Clipboard history stores everything you copy in iTerm2, which can include passwords, API keys, or sensitive command output. By default, the history is stored in plain text in your home directory, and any process with access to your user account can read it. If you share your computer, consider:

  • Disabling clipboard history entirely when not needed.
  • Deleting the history file regularly (it’s in ~/Library/Application Support/iTerm2/).
  • Using iTerm2’s “Clear” button in the history window to remove all entries.

There is no built-in encryption for the history file. For highly sensitive work, you may prefer to use a password manager and avoid copying secrets into the terminal at all.

Frequently Asked Questions

How do I clear the entire clipboard history in iTerm2?

Open the history window with Cmd+Shift+H, then click the “Clear” button at the bottom left. This removes all saved entries. You can also delete the history file manually while iTerm2 is closed.

Can I make iTerm2 not save certain items?

No, iTerm2 does not offer per-item exclusions. However, you can temporarily disable history by unchecking “Save copy/paste history to disk” in Preferences. There is no shortcut to pause it.

Why does my clipboard history disappear after restart?

If you enabled the option but the history is empty after restart, check that the “Save copy/paste history to disk” box is still checked. Some users report that the setting resets after an iTerm2 update. Also, if you deleted the history file, it will start fresh.

Does clipboard history work in tmux or screen sessions?

Yes, iTerm2 records copies and selections even inside tmux or screen, because it operates at the terminal emulator level. However, if you copy inside tmux using tmux’s own copy mode, that may not register as a copy in iTerm2 unless you use the mouse selection.

Can I sync clipboard history between Mac and iPhone?

No, iTerm2’s clipboard history is local to your Mac. It does not sync with iOS or other devices. If you need cross-device clipboard, you’d use Apple’s Universal Clipboard, but that only transfers the most recent item.

Is there a way to increase the number of saved entries?

Yes, in Preferences > General, under “Maximum number of entries,” you can set a higher number (e.g., 5000). Keep in mind that a very large history may slow down the search panel slightly.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →