A library to provide automatic paging for console output
Low maintenance activity. Last release 10 months ago, commits in 0 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install autopageautopage
Autopage is a Python library to
automatically display terminal output from a program in a pager (like less)
whenever you need it, and never when you don't. And it only takes one line of
code.
You know how some CLI programs like git (and a handful of others, including
man and systemctl) automatically pipe their output to less? Except not if
there's less than one screen's worth of data. And if you redirect the output to
a file or a pipe, it does the right thing instead. Colours are preserved. Don't
you wish all programs worked like that? Now at least all of your Python
programs can.
License
© 2020-2026 by Zane Bitter
Open Source licensed under the terms of the Apache Software License, version 2.0.
Installation
Autopage is available from PyPI. The
easiest way to install (preferably in a virtualenv virtual environment) is
with pip:
$ pip install autopage
On Fedora and CentOS/RHEL
Autopage is packaged for Fedora 35 and later, and EPEL 9. To install:
# dnf install python3-autopage
Copr repositories are available for older versions of Fedora and EPEL. Before attempting to install on those versions, first enable the copr repository:
# dnf copr enable zaneb/autopage
On Ubuntu and Debian
Autopage is packaged for Ubuntu jammy and later, and for Debian bookworm. To install:
# apt-get install python3-autopage
A PPA is available for older versions of Ubuntu. Before attempting to install on those versions, first enable the PPA:
# add-apt-repository ppa:zaneb/autopage
# apt-get update
On Gentoo
Autopage is packaged for Gentoo. To install:
# emerge dev-python/autopage
Basic Use
The AutoPager class provides a context manager that furnishes the output
stream to write to. Here is a basic example that reads from stdin and outputs
to a pager connected to stdout: