I use this everyday
Based on NetworkChuck's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
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?
What exact mechanism turns terminal pipelines into clipboard operations?
How do aliases make this usable day-to-day?
What changes when the clipboard workflow must work on a remote Linux server?
How does SSH configuration enable clipboard magic across machines?
Review Questions
- How would you test that PB copy and PB paste aliases are working correctly after editing ~/.bashrc?
- What two prerequisites must be satisfied on a remote Linux server to make clipboard piping work over SSH?
- Why do aliases need to be recreated on the remote server rather than relying on the local ~/.bashrc?
Key Points
- 1
Install xclip on Linux/WSL to provide terminal-to-clipboard functionality similar to macOS PB copy/PB paste.
- 2
Create bash aliases in ~/.bashrc so PB copy pipes stdin into the clipboard and PB paste outputs the clipboard to stdout.
- 3
Use piping to move large text blocks or command output directly into the clipboard without manual selection.
- 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
Add the same PB copy/PB paste aliases to the remote server’s shell configuration because local aliases do not transfer.
- 6
Connect with ssh -X to force X11 forwarding when logging into the remote server.
- 7
This approach is intended for Linux-to-Linux (including WSL-to-Linux) and is not recommended for Windows-to-Linux SSH scenarios.