GitHub - dawsonhuang0/Less-Pager-Mini: A scrollable terminal pager for Node.js with less-style navigation.

GitHub

3 min read Original article ↗

Logo

A lightweight terminal pager inspired by less, written in TypeScript for Node.js CLI apps.

npm downloads Platform Build Status

Table of Contents
  1. Getting Started
  2. Usage
  3. About The Project
  4. Feedback
  5. Contributing
  6. Acknowledgments
  7. License

Getting Started

Follow these simple steps to install Less-Pager-Mini.

Prerequisites

Make sure you have the following installed:

  • Node.js (v18 or higher)
  • npm (comes with Node.js)

Installation

Install Less-Pager-Mini via npm:

If you want to use it directly from your terminal:

Usage

Terminal:

Use lmn anywhere you'd use less — same keys, same flags:

lmn file.txt          # page a file
lmn -N app.log        # any less option works
cmd | lmn             # page piped output
lmn huge-500GB.log    # giant files open instantly

JavaScript / TypeScript:

import pager from 'less-pager-mini';

const example = ['a', 'b', 'c'];

await pager(example);
await pager(example, ['-N', '--chop-long-lines']);
await pager(example, ['-R'], { LESS: '-X' });

JavaScript calls are safe by default: interactive process escapes (!, #, |, and v) are disabled. The lmn executable keeps them enabled unless it is started with --no-shell.

Function Parameters

input: Any unknown input to page.

args: Less arguments as an array, spelled the way less documents them — ['-N', '--chop-long-lines', '+G']. They are scanned in order, so a later one overrides an earlier one, and an option may repeat.

env: An environment overlay for this call — the variables less consults (LESS, LESSOPEN, LESSSECURE, ...). $LESS is scanned before args, as it is before argv on a command line.

Featuring Arguments

You can use the following flags in args:

--examine-file: Treats the input as file path(s) and reads from disk, like naming them on the command line.

Example input:

or

[
  'a.txt',
  'b.md',
  'c' // Ignored
]

--tab-object: JSON.stringifies the input object indented with \t. You can adjust tab stops using the --tabs option.

off:
["a","b",["c","d"]]
{"a":1,"b":2,"c":{"d":3}}

on:
[
  "a",
  "b",
  [
    "c",
    "d"
  ]
]
{
  "a": 1,
  "b": 2,
  "c": {
    "d": 3
  }
}

--use-js-regexp: Searches with JavaScript's RegExp. Off by default — compiling POSIX-compatible regex patterns with posix-regex.

--lesskey-help: Displays the syntax of lesskey files.

--view-lesskey: Shows the lesskeys in use — v edits and re-applies the one on screen; creates ~/.lesskey if no lesskey is in use.

Notice:

--examine-file and --tab-object are not supported in lmn.

About The Project

Want to glance your array or objects, but scrolling through terminal feels painful? This tool got your back.

Less-Pager-Mini is a lightweight pager that lets you scroll massive terminal output with ease and precision.

Whether you're debugging, dumping logs, or previewing data structures — this pager helps you scroll fast without getting lost in overwhelming output.

  • 🔁 Familiar Commands – Inherits command keys from less
  • 📦 Minimal Dependencies – Lightweight, stable, and portable
  • 🖥️ Pure Terminal UX – Replicates 99% of the less experience

Roadmap

  • COMMAND MODE
  • MOVING
  • SEARCHING
  • JUMPING
  • CHANGING FILES
  • MISCELLANEOUS COMMANDS
  • OPTIONS
  • LINE EDITING
  • Custom Key-Bindings (lesskey)
  • Start up via lmn command directly from terminal
  • Load 1TB file instantly
  • Support wide-character (emoji, CJK, etc.) rendering
  • Support help page

Built With

TypeScript Node.js ESLint Vitest Husky ANSI Escape Codes

Feedback

Found something odd or came up with a bright improvement?
Feel free to open an issue — contributions and feedback are always welcome!

Contributing

Contributions are welcome! If you have suggestions, improvements, or bug fixes, feel free to:

  • Fork the repo
  • Create a new branch
  • Make your changes
  • Open a pull request

Please follow the coding style and write clear commit messages.
Let’s make Less-Pager-Mini better together!

Acknowledgments

  • Inspired by less by Mark Nudelman – the legendary terminal pager that set the standard.

License

Distributed under the MIT License.
See LICENSE for more information.