nojhan/liquidprompt — pull request #339 by iKevinY (2014-12-24 21:27:05+00:00)
Title: Add support for more hostname colours

I noticed that the hostname colours only support 6 different colours, even on terminals where many more colours are available. I used the following command to check all of the available colours on my `xterm-256color` terminal with two different colour schemes (the default OS X theme with a white background and a darker one that I use on a regular basis):

```bash
for i in {1..255}; do tput setaf $i; echo -n "$i "; done
```

![Light](https://cloud.githubusercontent.com/assets/2434728/5551102/3d89a250-8b70-11e4-9304-6f970a4429a4.png)
![Dark](https://cloud.githubusercontent.com/assets/2434728/5551103/3d8aedea-8b70-11e4-9d8e-183a8372b7ac.png)

On the white background, there is an issue with colours 226–231 being extremely difficult (or impossible) to read. Therefore, I opted to use `tput colors` to detect the number of colours that are available, and taking 75% of those colours. This has a couple benefits:

* The previous behaviour of the hostname colour algorithm chose a random colour in the interval [1, 6]. This new algorithm maintains this behaviour exactly when the output of `tput colors` is 8.
* 75% of 256 is 192, and choosing a colour in the interval [1, 192] avoids the use of colours 226–231 on `xterm-256color` terminals.

However, I'm not too certain about how well this solution will work on other systems, since I've only tested it on my OS X machine. Is it reasonable to assume that `tput colors` will be available everywhere?