Tag Archives: oneliner

Sending data to the clipboard from command line

26 Apr

In several occasions I find myself catting some file and then having to select the entire text with the mouse. If I want to keep my hands on the keyboard, I have to do a vim file, ggVG, “+y, :q.

Well, I found a way to do it faster and nicer simply by piping to the clipboard, thanks to xclip.

To use it, just install it and configure an alias in your .bashrc file, as follows:

$ sudo apt-get install xclip
$ alias clipboard='xclip -selection clipboard'

Then, when you need to do something like configuring your SSH key in GitHub, you just:

$ cat ~/.ssh/id_rsa.pub | clipboard

Thanks to Brian Racer for this snippet!

Advertisements

One-liner for downloading and extracting a tar.gz

18 Nov

I’m not the typical Linux one-linerd, but there are some that I find very useful.

Why execute 3 commands to download a tar.gz file, extract its contents and delete the archive, when actually there’s no need to store the archive physically (you only care about its contents) and you could save one command in the process?

So that’s why I love
wget -O- <url> | tar zxv
I tried the same for zip files but it doesn’t work. According to man unzip:

Archives read from standard input are not yet supported, except with funzip (and then only the first member of the archive can be extracted).

If anyone knows a workaround, it will be very appreciated!

 

%d bloggers like this: