Use Xclip For Quick Copy and Paste in Linux Terminal

If you’re a Linux audience, specifically one that enjoys kneading in the incurable, one product that can usually readjust how you take care of message on your Linux incurable is xclip. Instead of stressing message through your computer system mouse, correct-clicking, and also after that pasting it someplace else, you can tube message correct into xclip, and also it will immediately modernize your clipboard. From there, you can paste it into a document, an email, or even one more incurable residence window gaining serviceability of a speedy Ctrl + V.
Table of Ingredients
- Soliciting Started through Xclip
- Photocopy & Paste Without a Computer mouse
- Gain the Enterprises Process Even Paltry
- Is It Rewarding to Utilization Xclip?
xclip is useful enough to take care of several ranges of information, not simply unassuming message. Whether you’re reproducing code, commands, or arrangement records, xclip handles all this web content repetitively.
Chit: xclip single works through X11 and also won’t sprinted on Wayland. If you’re on Wayland, utilise wl-clipboard (wl-xerox and also wl-paste) instead.
Soliciting Started through Xclip
To avail started through xclip, you’ll need to mount it gaining serviceability of your product’s default package company. For instance, if you’re running Ubuntu decide I am, utilise:
sudo apt install xclip
For Arc-based distros, you’d utilise:
sudo pacman -S xclip
Fedora or CentOS/RHEL, sprinted this:
sudo dnf install xclip
As conveniently as it’s mounted, you’re ready to rumble!
Photocopy & Paste Without a Computer mouse
Once you utilise xclip, you’re connecting correct through your product’s clipboard buffer. Whether you’re reproducing upshot from a command or the contents of a record, xclip testimonials from perfunctory input (stdin) and also forges to the X hodgepodge (clipboard). In petite specifications: whatever you tube into xclip will have to your clipboard.
For instance, if you have a record termed “notes.txt” and also want to xerox all its contents, you can sprinted:
cat notes.txt | xclip -selection clipboard

This one petite pitch sends every little thing from “notes.txt” correct to your clipboard, simply as if you’d picked it by hand and also persuaded Ctrl + C.
To paste the contents into any type of document or incurable, simply utilise the secure Ctrl + V.
Pine to paste the clipboard contents ago into the incurable or utilise it in one more command? Utilization the -o
(upshot) solution:
xclip -o -selection clipboard
This command prints out whatever is currently in your clipboard. You can even reroute that upshot into a record decide this:
xclip -o -selection clipboard > my_copied_list.txt
Yet what if you single want to xerox a information portion of message from your records? In that capsule, you can utilise other Linux tools decide sed, grep, head, tail, or awk to filter the web content before piping it to xclip.
For instance, to xerox single nonsenses 5 via 10 from “notes.txt,” utilise:
sed -n '5,10p' notes.txt | xclip -selection clipboard
Listed below, the -n
flag restrictions the initially upshot, and also -p
tells sed to print single the identified nonsenses. The output is sent out to your clipboard, ready to paste. Also, if you’re kneading through screenshots or other image records, xclip can take care of them also.
Gain the Enterprises Process Even Paltry
One thing that actually outraged me was having to kind those long hodgepodge commands over and also over again. To mend this, I invented aliases in my “~/.bashrc” record to render the hodgepodge process easier and also sooner. Simply amenable your “~/.bashrc” record through any type of message editor:
nano ~/.bashrc
Next off, have these 2 nonsenses:
alias setclip="xclip -selection clipboard"
alias getclip="xclip -selection clipboard -o"

Reload it through:
source ~/.bashrc
Now, you can simply utilise setclip to xerox and also getclip to paste. For instance, to xerox all the record contents, sprinted:
cat notes.txt | setclip
To paste it into the incurable, sprinted:
getclip

That’s it! Zero added typing out those long commands every time.
Is It Rewarding to Utilization Xclip?
The petite rebuttal is yes. It’s far added advantageous than you believe. If you concoct manuscripts, job in the incurable all day, or take care of confidential mechanisms, this product can conserve you meaty time and also campaign.
Personally, I love it since it reinforces my efficacies while kneading in the incurable. I no longer have to shield versus, grab the computer system mouse, scroll via message, or risk absent something when reproducing. It’s in addition uncomfortably advantageous for founders and also sysadmins that in some housings xerox logs, impoverished answers posts, or arrangement blocks.
Yet, if you want added functions decide keeping a history, running manuscripts, or taking care of images, try a clipboard company such as CopyQ, cliphist, Autocutsel and also the Clipboard Job.
Final Concepts
The xclip command isn’t some overengineered or confusing product. It’s petite—yet when you overture gaining serviceability of it, you’ll awe how you ever operated without it. Simply by disclosing commands decide these, you can augment your workflow and also stay focused in the incurable.
If you shelter’t risked it yet, placement it a go. Place it, sprinted a couple of checkups, and also go to how much smoother your reproducing and also pasting becomes. And bear in mind, xclip isn’t the single product out there. There are plenty of other Linux commands that can bolster your performance. You can even ponder matching your secure command-pitch tools through newer, added productive selections.