Asides

Easy coloured tail output

As part of my job I’m often watching the output of a tail -f <filename> command run down my terminal window… and on my development and quite testing machines this is all well and good.

But what if the system is a pretty busy one? Well here it can be hard to spot the messages that might be of interest to you. And that is why I use a little trick to highlight a specific word in the output.

How to highlight words in tail output?

1) Basically add the following lines to your .bashrc  file

ctail(){
  tail -f $1 | perl -pe 's/'$2'/\e[1;31;43m$&\e[0m/g'
}

This adds a function available to you in bash that can be then be used to do exactly what you want. Say for example you want to highlight all instances of Error when tailing a file called foo.txt you can run the following.

ctail foo.txt Error

Adding a mobile number to Twitter

For a side project I’m currently working on (codenamed Shedwina, more details to follow later) I wanted to set up a Twitter NodeJS bot. On logging into https://dev.twitter.com as my bot account and trying to create a new app I got the error message that the account needed to have a mobile number associated with it. This in itself shouldn’t have been an issue but to set up a mobile number you need to send an SMS to a shortcode… sadly there was no option for EE in the UK and the long number option failed to work even after a few attempts.

I then come up with an idea… and it worked. Basically I installed the official Twitter client on my phone and checked the box which allowed the use of my phone number in the set-up phase. This has the desired affect and upon the next attempt at creating the app over at https://dev.twitter.com all worked like a dream.