Skip to content

Instantly share code, notes, and snippets.

@diegopacheco
Last active February 22, 2025 18:44
Show Gist options
  • Save diegopacheco/75de31680b3eaeb8824e994b81889f82 to your computer and use it in GitHub Desktop.
Save diegopacheco/75de31680b3eaeb8824e994b81889f82 to your computer and use it in GitHub Desktop.
pbpaste && pbcopy for Ubuntu Linux 20.04

Install

sudo apt-get install xclip -y

Create Alias

alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'

Try out

pbcopy < /proc/cpuinfo 
pbpaste > tst.txt
cat tst.txt 
@delovelady
Copy link

delovelady commented Dec 22, 2024

This does not work for me on UBUNTU 22.04LTS nor 24.04LTS. I get "Error: Cannot open display (null)" error on all Ubuntu systems that I have. Man xclip does not show me a workaround, although that itself (in the "I hate manpages without examples" section) seems to imply that this "solution" should work. In fairness, they don't actually state that, but the examples are clearly terminal examples. I guess they just assume I'm smart enough to "know" this cannot be done in an SSH session or at the console. (That would be an incorrect assumption. :\)

@Toufa7
Copy link

Toufa7 commented Jan 15, 2025

It's working perfectly on Ubuntu 24.04.1 LTS

@TianPSeventh
Copy link

it works perfectly thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment