walles / moar

Moar is a pager. It's designed to just do the right thing without any configuration.
Other
585 stars 17 forks source link
console console-application moar pager

Linux CI Windows CI

Moar is a pager. It reads and displays UTF-8 encoded text from files or pipelines.

moar is designed to just do the right thing without any configuration:

Moar displaying its own source code

The intention is that Moar should be trivial to get into if you have previously been using Less. If you come from Less and find Moar confusing or hard to migrate to, please report it!

Doing the right thing includes:

For compatibility reasons, moar uses the formats declared in these environment variables if present:

For configurability reasons, moar reads extra command line options from the MOAR environment variable.

Moar is used as the default pager by:

Installing

Using Homebrew

brew install moar

Then whenever you want to upgrade to the latest release:

brew upgrade

Using MacPorts

sudo port install moar

More info here.

Using Gentoo

emerge --ask --verbose sys-apps/moar

More info here.

Using Arch Linux

yay -S moar

More info here.

Manual Install

  1. Download moar for your platform from https://github.com/walles/moar/releases/latest
  2. chmod a+x moar-*-*-*
  3. sudo mv moar-*-*-* /usr/local/bin/moar

And now you can just invoke moar from the prompt!

Try moar --help to see options.

If a binary for your platform is not available, please file a ticket or contact johan.walles@gmail.com.

Debian / Ubuntu

A Request for Packaging is open, please help!

Configuring

Do moar --help for an up to date list of options.

Environment variable MOAR can be used to set default options.

For example:

export MOAR='--statusbar=bold --no-linenumbers'

Setting moar as your default pager

Set it as your default pager by adding...

export PAGER=/usr/local/bin/moar

... to your .bashrc.

Issues

Issues are tracked here, or you can send questions to johan.walles@gmail.com.

Packaging

If you package moar, do include the man page in your package.

Embedding

Here's one way to embed moar in your app:

package main

import (
    "bytes"
    "fmt"

    "github.com/walles/moar/m"
)

func main() {
    buf := new(bytes.Buffer)
    for range [99]struct{}{} {
        fmt.Fprintln(buf, "Moar")
    }

    err := m.NewPager(m.NewReaderFromStream("Moar", buf)).Page()
    if err != nil {
        // Handle paging problems
        panic(err)
    }
}

m.Reader can also be initialized using NewReaderFromText() or NewReaderFromFilename().

Developing

You need the go tools.

Run tests:

./test.sh

Launch the manual test suite:

./manual-test.sh

To run tests in 32 bit mode, either do GOARCH=386 ./test.sh if you're on Linux, or docker build . -f Dockerfile-test-386 (tested on macOS).

Run microbenchmarks:

go test -benchmem -run='^$' -bench=. . ./...

Profiling BenchmarkPlainTextSearch(). Try replacing -alloc_objects with -alloc_space or change the -focus function:

go test -memprofilerate 1 -memprofile profile.out -benchmem -run='^$' -bench '^BenchmarkPlainTextSearch$' github.com/walles/moar/m && go tool pprof -alloc_objects -focus findFirstHit -relative_percentages -web profile.out

Build + run:

./moar.sh ...

Install (into /usr/local/bin) from source:

./install.sh

Making a new Release

Make sure that screenshot.png matches moar's current UI. If it doesn't, scale a window to 81x16 characters and make a new one.

Execute release.sh and follow instructions.

TODO

Done