Skip to content

Instantly share code, notes, and snippets.

@haileys
Created January 5, 2014 12:49
Show Gist options
  • Save haileys/8267801 to your computer and use it in GitHub Desktop.
Save haileys/8267801 to your computer and use it in GitHub Desktop.
def pipe_to_pager(pager = "less")
r, w = IO.pipe
if fork
# parent
$stdin.reopen(r)
w.close
exec pager
else
# child
r.close
$stdout.reopen(w)
end
end
if $stdout.tty?
pipe_to_pager
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment