Get AI summaries of any video or article — Sign up free
I use this everyday thumbnail

I use this everyday

NetworkChuck·
4 min read

Based on NetworkChuck's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

Install xclip on Linux/WSL to provide terminal-to-clipboard functionality similar to macOS PB copy/PB paste.

Briefing

Copying and pasting through the terminal becomes dramatically more useful when the clipboard is wired into command-line workflows—especially for Linux and Windows users running WSL. The core idea is to install a small clipboard utility on the machine you’re working in, then use two terminal commands—one to push text into the system clipboard and one to pull text out—so you can pipe files, command output, or whole text blocks directly into other tools.

On macOS, clipboard commands already exist (PB copy / PB paste), but they aren’t available by default on Linux or Windows. The workaround uses a command-line program called xclip (installed via apt-get) to create equivalents: PB copy becomes a command that sends stdin to the clipboard, and PB paste becomes a command that outputs the clipboard contents to stdout. With those in place, terminal operations that normally end in a file or a screen can instead end up in the clipboard. That enables workflows like piping a large transcript into the clipboard, copying an entire article from a browser into a terminal pipeline, or feeding clipboard text into another command (the transcript mentions using a summarization tool called “fabric” as an example).

To avoid typing long commands every time, the instructions define shell aliases in ~/.bashrc. The aliases are named PB copy and PB paste and map to xclip’s “input from stdin” and “output to stdout” modes. After saving the updated bashrc and reloading it with source ~/.bashrc, a quick test—echoing a line and piping it into PB copy, then piping PB paste back into the terminal—confirms the clipboard round-trip works.

The second half tackles a more advanced scenario: copying and pasting while logged into a remote Linux server from a local Linux/WSL environment. Clipboard access doesn’t automatically carry over to another machine, so the remote server must be prepared. Two requirements are emphasized: xclip must be installed on the remote server, and X11 forwarding must be enabled so a program can run on the remote host while displaying its “graphics” (and clipboard-related behavior) through the local display. The transcript walks through checking /etc/ssh/sshd_config for X11Forwarding yes (and ensuring it isn’t commented out), restarting SSH if changes are needed, and adding the same bash aliases on the remote server because aliases defined locally won’t exist there.

Finally, the SSH connection uses a special flag—ssh -X—to force X11 forwarding. With that in place, the same PB copy / PB paste aliases work on the remote server, enabling clipboard-based copy/paste even across machines. The result is a practical, repeatable terminal habit that turns clipboard operations into pipeline-friendly building blocks rather than manual copy/paste steps.

Cornell Notes

The transcript shows how to make terminal copy/paste work on Linux and WSL by recreating macOS-style PB copy and PB paste using xclip. After installing xclip, users define bash aliases in ~/.bashrc so PB copy pipes stdin into the system clipboard and PB paste prints the clipboard contents to stdout. This enables workflows like piping command output or large text blocks directly into other terminal commands. For remote servers, clipboard piping requires xclip installed on the remote machine and X11 forwarding enabled in /etc/ssh/sshd_config, plus SSH connections using ssh -X. Aliases must also be added on the remote server because local aliases don’t transfer automatically.

Why do PB copy and PB paste work out of the box on macOS but not on Linux or Windows/WSL?

PB copy and PB paste are macOS-specific clipboard commands. On Linux and on Windows (including WSL), those commands aren’t available by default, so the transcript replaces them with xclip-based equivalents.

What exact mechanism turns terminal pipelines into clipboard operations?

Install xclip and use it in two directions: PB copy is implemented as xclip reading from stdin (Excel -input -clipboard in the transcript’s command form), while PB paste is implemented as xclip writing clipboard contents to stdout (Excel -output -clipboard in the transcript’s command form). Piping text into PB copy pushes it into the clipboard; running PB paste prints clipboard text back into the terminal.

How do aliases make this usable day-to-day?

Because the underlying xclip commands are long, the transcript instructs adding aliases to ~/.bashrc: alias pbcopy (named PB copy in the transcript) maps to the xclip input command, and alias pb paste maps to the xclip output command. After saving and reloading with source ~/.bashrc, the short alias names behave like the macOS commands.

What changes when the clipboard workflow must work on a remote Linux server?

Clipboard behavior must be set up on the remote host. The transcript requires installing xclip on the remote server and enabling X11 forwarding in /etc/ssh/sshd_config (X11Forwarding yes, not commented out). It also notes that this scenario is for Linux-to-Linux (or WSL-to-Linux) and warns that Windows-to-Linux doesn’t work well.

How does SSH configuration enable clipboard magic across machines?

The remote server needs X11 forwarding enabled, and the SSH client must connect with ssh -X to force X11 forwarding. With that, the xclip-based clipboard commands can function while the program runs remotely but uses the local display context.

Review Questions

  1. How would you test that PB copy and PB paste aliases are working correctly after editing ~/.bashrc?
  2. What two prerequisites must be satisfied on a remote Linux server to make clipboard piping work over SSH?
  3. Why do aliases need to be recreated on the remote server rather than relying on the local ~/.bashrc?

Key Points

  1. 1

    Install xclip on Linux/WSL to provide terminal-to-clipboard functionality similar to macOS PB copy/PB paste.

  2. 2

    Create bash aliases in ~/.bashrc so PB copy pipes stdin into the clipboard and PB paste outputs the clipboard to stdout.

  3. 3

    Use piping to move large text blocks or command output directly into the clipboard without manual selection.

  4. 4

    For remote clipboard workflows, install xclip on the remote server and enable X11 forwarding in /etc/ssh/sshd_config (X11Forwarding yes, not commented).

  5. 5

    Add the same PB copy/PB paste aliases to the remote server’s shell configuration because local aliases do not transfer.

  6. 6

    Connect with ssh -X to force X11 forwarding when logging into the remote server.

  7. 7

    This approach is intended for Linux-to-Linux (including WSL-to-Linux) and is not recommended for Windows-to-Linux SSH scenarios.

Highlights

xclip plus two aliases turns terminal pipelines into clipboard operations: pipe into PB copy, then pipe from PB paste.
Remote clipboard support hinges on X11 forwarding: X11Forwarding must be enabled on the server and SSH must use ssh -X.
Aliases must be defined on the remote host too; ~/.bashrc settings on the local machine won’t apply after SSH.
The workflow enables practical text handling—piping transcripts or article text into other terminal tools—without manual copy/paste.

Topics

  • Terminal Clipboard
  • xclip
  • Bash Aliases
  • SSH X11 Forwarding
  • WSL Remote Workflows

Mentioned