File: pager.rb

package info (click to toggle)
ruby-file-tail 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 208 kB
  • sloc: ruby: 890; makefile: 3
file content (17 lines) | stat: -rwxr-xr-x 419 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env ruby
# A poor man's pager... :)

require 'file/tail'

filename = ARGV.shift or fail "Usage: #$0 filename [height]"
height = (ARGV.shift || ENV['LINES'] || 23).to_i - 1

File::Tail::Logfile.open(filename, :break_if_eof => true) do |log|
  begin
    log.tail(height) { |line| puts line }
    print "Press return key to continue!" ; gets
    print ""
    redo
  rescue File::Tail::BreakException
  end
end