Use pbcopy and pbpaste on Ubuntu
After using Mac for a couple of years for work reasons I got used to the
pbcopy
and pbpaste
commands to copy and paste stuff from the terminal.
Now that I’m back to Linux on my daily driver I figured out a simple way to do
the same.
The process is straightforward:
Install xclip:
sudo apt install xclip
Edit your
.bash_aliases
and add the new commands:alias pbcopy='xclip -selection clipboard' alias pbpaste='xclip -selection clipboard -o'
Reload your bash configuration file:
source ~/.bashrc
Test your new aliases:
echo "Hello World!" | pbcopy pbpaste
You see “Hello World!” copied by your first command and pasted by the second. That’s it!