Tag Archives: command line

Colorized tail

28 May

I was tailing a logfile and I wanted to colorize some specific keywords in it. I found Andreas Schamanek’s mycolorize which serves perfectly for the purpose.

Download it and use it by doing

$ tail logfile | ~/mycolorize color 'regexp'

You can check additional examples and documentation on the website.


Clone-a-database one-liner

9 May

I had to clone a remote MySQL database into my Ubuntu notebook, and I just felt like doing a one-liner for it.

$ mysqladmin -f -uroot create sandbox &&
ssh luisfarzati@mydatabasehost.com "mysqldump -uroot sandbox | gzip -f" | gunzip | mysql -uroot sandbox

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!

%d bloggers like this: