Overview
Theclip command reads content from standard input (stdin) and copies it to your system clipboard. It’s perfect for capturing command output, file contents, or piped data for easy pasting.
Syntax
Parameters
This command takes no parameters. It reads all input from stdin.Usage Examples
Output
When successful, the command displays:How It Works
Stdin Reading
The command:- Waits for stdin input (blocks if no input is piped)
- Reads all available stdin content
- Passes the content to the system clipboard
- Confirms the operation
Clipboard Integration
Uses thecopy-paste npm package which:
- Detects your operating system
- Uses the appropriate clipboard mechanism:
- macOS:
pbcopy - Linux:
xcliporxsel - Windows:
clip
- macOS:
Platform Requirements
macOS
Works out of the box. Uses the built-in
pbcopy command.Linux
Install on Ubuntu/Debian:Windows
Uses the built-in
clip command. Works out of the box.Common Patterns
Debugging
Configuration Sharing
Code Sharing
Data Processing
Technical Details
Implementation
The command uses:- copy-paste library for cross-platform clipboard access
- Bun’s stdin reading utilities
- Synchronous clipboard operation
Stdin Reading
The stdin content is read using:- Reads from
process.stdin - Waits for EOF (End of File)
- Returns the complete input as a string
Error Handling
No Stdin Input
If you run the command without piping input:Ctrl+D (Unix) or Ctrl+Z (Windows) to signal EOF.
Clipboard Access Errors
If clipboard access fails (missing dependencies on Linux):- The command may throw an error
- Install the required clipboard utility for your platform
Notes
The entire stdin is read into memory before copying. For very large inputs, this may consume significant memory.
The clipboard content persists after the command exits, allowing you to paste it anywhere.
Related Commands
- qr - Generate QR codes from stdin
- share-discord - Share stdin content to Discord
