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 and this is my "lite" technical blog!

I'm a passionate DevOps, Linux system engineer, Cloud/Kubernetes specialist, Free/Open source geek, author, interested in environment, calligraphy, and I believe that “Details Matter”!

DevOps transformation, automation, data, and metrics are my preferred areas. I have a built-in monitoring chip, and too lazy to do anything manually :D

Popular Posts