05/05/2016

Emulate pbcopy and pbpaste in Linux with xsel - Bash

One of nice tools I did use before are "pbcopy" and "pbpaste", which are simply copy and paste any data to and from clipboard in command line! It's a Mac OS tool, and unfortunately there is no port for Linux!

However you still can get the same functionality on Linux using "xsel" command! But you need some modification to make it works as same as pb tools.

Just edit your ".bashrc" file and add:
alias pcopy='xsel --clipboard --input'
alias ppaste='xsel --clipboard --output'

Once you did, you can use them just like original ones. e.g. if you want to copy a content of file:
# Get data from another command.
echo 'Linux is awesome!' | pcopy

# Get data directly from a file.
pcopy < /etc/fstab

And if you want to past what you have currently in your clipboard, just use pbpaste!
Now enjoy your Linux system! It's the best system as you know :-)
Powered by Blogger.

Hello, my name is Ahmed AbouZaid, I'm a passionate Tech Lead DevOps Engineer. 👋

I specialize in Cloud-Native and Kubernetes. I'm also a Free/Open source geek and book author. My favorite topics are DevOps transformation, DevSecOps, automation, data, and metrics.

More about me ➡️

Contact Me

Name

Email *

Message *

Start Your DevOps Engineer Journey!

Start Your DevOps Engineer Journey!
Start your DevOps career for free the Agile way in 2024 with the Dynamic DevOps Roadmap ⭐

Latest Post

Bootstrap Cloud-Native bootstrappers like Crossplane with K3d - Automation

I created a logo for the Crossplane Bootstrapper because all good projects deserve a logo. 😁 TL;DR ...

Popular Posts

Blog Archive