shorter for-loops in zsh

When running a for-loop in zsh, you can skip do-done part, leaving only command, for example:

% for day in Mon Tue Wed Thu; date -d "next $day"
Mon Apr 25 00:00:00 CEST 2016
Tue Apr 26 00:00:00 CEST 2016
Wed Apr 27 00:00:00 CEST 2016
Thu Apr 28 00:00:00 CEST 2016

Caveat: this doesn’t work on multiple commands in one loop — for day in Mon Tue Wed Thu; echo $day; date -d "next $day" won’t work as expected

install rpm by url

For those Debian-inclined, this may be surprising. You can install RPMs by providing an URL to either yum or rpm -i:

rpm -i <a href="https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm">https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm</a>
yum install <a href="https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm">https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm</a>

automatically set prompt colour based on hostname

When logging on multiple machines with synchronized ~/.bashrc / ~/.zshrc you probably don’t want to set PS1 on each machine separately. Solution based on hostname will be handy.

To derive user@hostname (or any other host-identifying command) into uniformly-distributed colours, use:

_host_colour=$(echo $(whoami)@$(hostname -f) | sum | awk "{print  $1 % 256 }")

GNU tool sum generates simple, short checksum which are then shortened down to 256 (the default Xterm colour count).
Now add the variable to your PS1:

# Bash
export PS1="[33[38;5;${_host_colour}m]u@h[33[0m] % "

# Zsh (requires module colors)
export PS1="%F{${_host_colour}}%n@%m%f %% "

Protip: If you want to change colour per-host, just set variable _host_colour. You can do it even after PS1 was set.