Customize and improve Terminal (Mac OS)

Today, I just wanted to share with you a simple way to customize your Terminal and improve its readability.

Color theme

First of all, I will recommand you to install a new theme for your Terminal. Of course, you can also customize it yourself, but there is already great themes available like this ones :

After choosing your theme, don’t forget to click on “Default” to enable this theme on every new Terminal window.

Font

The default font in Terminal is Andale Mono, which is a good font, but you could customize it. My favorite for this is Anonymous Pro, but of course you can choose your own, just be aware to choose a Monospace font.

Download Anonymous Pro

Increase size

Depending on the font you choose, you can increase its size, the way you like it. Personally, I choosed 14px for Anonymous Pro.

Bold fonts or antialias text

I would recommand you to check at least one of this two checkbox :

  • Use bold fonts
  • Antialias text

This will hightly improve the readability of your font, especially if your using a retina screen.

Improve the syntax coloration and ls command

We will change the syntax coloration of the Terminal and get something like this.

Customized Terminal screen
Customized Terminal screen

To do that, we will need to edit our .bash_profile file. To open this file, type this in your Terminal :

Or edit it directly with nano or vim.

Then, past this lines at the beginning of the file and save it.

That’s it, your ready to go! Open a new Terminal and start doing awesome stuff!

Source: OSXdaily

 

Check the weather in one command line

Are you using the Terminal (or any other command line tools) everyday ? npm, grunt, gulp, bower, etc. are your most written words ? Well then, you will be happy to know that you can now also check the weather in your favorite tool, with a simple command line:

Here is an example of the result:

Weather in the Terminal

Readable and faster “for” loops in PHP

After some discussions on Twitter, I would like to show you some ways to write for loops in PHP, but more readable and fast.

Classic for loop

The most common, and probably used, way to write a for loop, is by using the for keyword like this :

foreach with range()

But you could write the same loop with a foreach, and using the range PHP function :

This way is more readable, but sadly, it’s a lot much slower : 2 to 5 times slower than the for loop.

while loop and decrementation

Another readable way to make something similar to a for loop, is by decrementing in a while like this :

No, the arrow (–>) is not a new operator, it’s just the decrement operator — with the comparison operator >. You could also write it like this :

What about the speed ? Well, it’s 2 times faster than the for loop ;). This way, you have a great readability and speed on your loop.

Check it online or try it yourself :