Skip to main content

Chapter 7: Copy Mode - Scroll, Search and Copy Terminal Output

So far, you've learned how to organize your tmux workspace using sessions, windows, and panes. But there's one problem you'll run into very quickly.

Your terminal can produce a lot of output.

Maybe you're checking application logs. Maybe a command printed hundreds of lines. Maybe an error happened somewhere near the top of the output.

You try to scroll up and suddenly you're not looking at the part you need.

This is where tmux copy mode becomes useful.

Copy mode lets you move through the history of a tmux pane, search through that output, select text, and copy it.

In this chapter, we'll learn how to use it without getting into complicated clipboard configuration. By the end, you'll be able to inspect large amounts of terminal output and grab the information you need.

Why Do We Need Copy Mode?

Let's start with a simple example.

Run:

seq 1 100

You'll get:

1
2
3
4
...
97
98
99
100

Now imagine this wasn't 100 lines but several thousand lines of application logs.

You might want to go back and find something that appeared earlier.

That's what copy mode is designed for.

Instead of treating your terminal as a screen that only shows the latest output, tmux gives you a way to scroll through the scrollback history of the pane.

0:00
/0:14

Scrollback history in copy mode

Move Through Terminal History

Once you're in copy mode, you can move through the output.

Use the arrow keys to move around:

โ†‘
โ†“
โ†
โ†’

You can also use the Page Up and Page Down keys to move through larger sections of output.

For example:

Page Up   โ†’ Move back through output
Page Down โ†’ Move forward
0:00
/0:22

Moving through terminal history

You can also use the mouse wheel in environments where mouse support is enabled, but for now I want you to understand the actual tmux copy mode workflow.

This is particularly useful with logs.

Search Through Output

Scrolling is useful when you know roughly where the information is. But what if your log contains thousands of lines and you're looking specifically for:

Hit

You don't want to scroll through everything manually. You can search. While inside copy mode, press:

/ 

This will Scroll Down Search.

?

This will help to Scroll Up Search. Then try to search for the keyword you are looking for in the search history.

Hit

Press Enter. Tmux will search through the available history and take you to a matching result.

You can move to the next match using:

n

and search in the opposite direction with:

N

The exact search behavior can depend on the mode and configuration you're using, but the basic workflow is:

Ctrl+b [
   โ†“
/
   โ†“
Type search term
   โ†“
Enter
   โ†“
Inspect matching output
0:00
/0:16

Searching in the tmux copy mode

If you are not able to perform these set of commands you can set the following in the last of your tmux config file:

set -g mode-keys vi
set -g search-default-case-insensitive on

Select and Copy Text

Now let's do the second important job of copy mode. Suppose you've found an error like this:

 An error occurred during the signature verification.

You may want to copy that line and paste it somewhere else, likely your AI buddy. Inside copy mode, you can enter selection mode by pressing:

Space

Now move the cursor to select the text you need.

Depending on your tmux configuration and version, you can navigate through the text using the keyboard and extend the selection.

Once you've selected the text, press:

Enter

to copy the selected text into tmux's paste buffer.

The important workflow is:

Enter copy mode
      โ†“
Find the text
      โ†“
Start selection
      โ†“
Select text
      โ†“
Copy
0:00
/0:23

Select and copy text form output

Pasting What You Copied

Once you've copied something, tmux stores it in its paste buffer.

To paste the most recently copied text, use:

Ctrl+b ]

For example:

Ctrl+b [

Find and copy:

ERROR: connection refused

Then return to your shell and press:

Ctrl+b ]
0:00
/0:06

Pasting the recently copied output

The copied text will be pasted into the current pane. This is different from your operating system's normal clipboard.

Tmux maintains its own paste buffers, which means it can keep text copied from its terminal environment even when you're working inside a remote session.

Exiting Copy Mode

Once you're finished looking through the history, press:

q

This exits copy mode and returns you to the normal tmux pane.

So the complete basic workflow becomes:

Ctrl+b [
   โ†“
Copy mode
   โ†“
Scroll / Search
   โ†“
Select / Copy
   โ†“
Ctrl+b ]
   โ†“
Paste
   โ†“
q
   โ†“
Back to normal shell

You don't have to think about all of these operations every time.

Most of the time, you'll use copy mode because you need to inspect something that has already scrolled away.

What About Mouse Support?

You may have noticed that using the keyboard for copy mode can feel different from how you normally select text in a terminal.

Tmux also supports mouse interaction when mouse mode is enabled. For example, with mouse support configured, you can use the mouse to:

  • scroll through panes
  • select text
  • interact with panes and windows

We'll cover mouse support more properly when we introduce tmux configuration in the final chapter. For now, learn the keyboard-based copy mode workflow first.

That way, you won't depend on a particular terminal emulator or mouse setup.

In the next chapter, we'll build a complete real-world tmux workflow using sessions, windows, panes, persistence, and copy mode.

Updated on Sep 4, 2026