#!/usr/bin/env ruby
#
# 1t - hide cursor and last empty line in tail -f output
#
# Usage: tail -F /var/log/messages.log |1t

$stdout.sync = $stdin.sync = true

begin
  system 'tput', 'civis'

  while line = gets
    puts  unless $. == 1
    print line.chomp
  end
rescue Interrupt
  # handle <ctrl-c> exit
  puts 'exit'
ensure
  puts
  system 'tput', 'cnorm'
end
