Terminal can handle more than simple characters with special instructions.

Ruby

In ruby, you've the wonderful but simple rainbow

sudo gem install rainbow

It's easy to use :

puts "hello " + "colored".color(:red) + " world"

If you are an adventurer, you can do more. Wikipedia tells you everything about ANSI escape code. CSI in ruby is \e[.

With such tools, you can do the extraordinary spinning fan effect :

1000.times do |i|
  print "\e[3G\e[1m"
  print %w{ | / – \\ }[i % 4]
  print " \e[0m \e[8G"
  STDOUT.flush
  sleep 0.5
end

It's cute as a regex.

  1. You put the cursor in an absolute position (third place)
  2. You wont red color
  3. You draw a fan
  4. No more color
  5. Go to hell, cursor, I wont to see my fan

In ruby, when you puts, flush is implicit, but not with print .

No rake user can live without this gem.

The rest of the world

Every language got a library for that. I have trying colors for nodejs and colorama for Python