I've been using Linux and, more importantly, the command line for about five years now (ever since I got into Computer Science school). It's great, really. I love the command line with all my heart: it's simple, direct and fast. But there's some things you just can't do as in a GUI.
One negligible, annoying problem
Lately, I've been particularly busy doing networking stuff like copying (public) SSH keys from one machine and pasting them to the authorized_keys
file of another.
If you're not very familiar with SSH
or keys in general, don't worry, just picture a directory like this on my local machine:
.ssh
├── config
├── id_rsa
├── id_rsa.pub
└── known_hosts
And another one on a remote machine like this:
.ssh
├── authorized_keys
└── known_hosts
What I want to do is copy the contents of id_rsa.pub
and append them to authorized_keys
on the remote machine.
The solutions you don't want but will end up going for
cat id_rsa.pub
. Select the contents using a mouse (when you can).Ctrl+Shift+C
(to copy). Go to the remote machine.vim authorized_keys
.Ctrl+Shift+V
. Paste.scp id_rsa.pub remote_host_ip:/home/your_user/.ssh/mykey.pub
(copy theid_rsa.pub
file to the remote machine). Go to the remote machine.cat mykey.pub >> authorized_keys
(append the contents of the recently-copiedmykey.pub
file toauthorized_keys
).rm mykey.pub
.You use
xclip
. The clipboard command-line interface for the X desktop environment. It does exactly what you want, only that's completely cryptic and, liketar
, you'll never really remember that goddamn command and you'll have to google it every. single. time. For the sake of completeness here's one of the ways of doing this:
xclip -sel clip < ~/path/to/file.txt
What would you expect from xclip
instead? Probably something like this:
xclip /path/ti/file.txt
Oh gee, I wonder if anyone ever make something like tha-
The solution you really want
With xcreep
you can simply
xcreep /path/to/file.txt
And boom! It's on your clipboard.
Stupid right? I thought so too, and I've been using it daily for the past three months now. It's by far the most useful piece of code I've ever written.
Don't want to install a Go script? There's also a shell script for it!
Top comments (0)