Moor is a pager. It reads and displays UTF-8 encoded text from files or pipelines.
moor
is designed to just do the right thing without any configuration:
The intention is that Moor should be trivial to get into if you have previously been using Less. If you come from Less and find Moor confusing or hard to migrate to, please report it!
Doing the right thing includes:
- Syntax highlight source code by default using Chroma
- Search is incremental / find-as-you-type just like in Chrome or Emacs
- Filtering is incremental: Press & to filter the input interactively
- Search becomes case sensitive if you add any UPPER CASE characters to your search terms, just like in Emacs
- Regexp search if your search string is a valid regexp
- Snappy UI even on slow / large input by reading input in the background and using multi-threaded search
- Supports displaying ANSI color coded texts (like the output from
git diff
|riff
for example) - Supports UTF-8 input and output
- Transparent decompression when viewing compressed text
files
(
.gz
,.bz2
,.xz
,.zst
,.zstd
) or streams - The position in the file is always shown
- Supports word wrapping (on actual word boundaries) if requested using
--wrap
or by pressing w - Follows output as long as you are on the last line,
just like
tail -f
- Renders terminal hyperlinks properly
- Mouse Scrolling works out of the box (but look here for tradeoffs)
For compatibility reasons, moor
uses the formats declared in these environment variables if present:
LESS_TERMCAP_md
: Man page boldLESS_TERMCAP_us
: Man page underlineLESS_TERMCAP_so
: Status bar and search hits
For configurability reasons, moor
reads extra command line options from the
MOOR
environment variable.
Moor is used as the default pager by:
px
/ptop
,ps
andtop
for human beingsriff
, a diff filter highlighting which line parts have changed
Using Homebrew
moar
binary.
Both macOS and Linux users can use Homebrew to install. See below for distro specific instructions.
brew install moar
Then whenever you want to upgrade to the latest release:
brew upgrade
Using MacPorts
moar
binary.
sudo port install moar
More info here.
Using Gentoo
moar
binary.
emerge --ask --verbose sys-apps/moar
More info here.
Using Arch Linux
moar
binary.
yay -S moar
More info here.
Nobody has stepped up to maintain moor
for Debian.
If you want to maintain the moor
packaging for
Debian, that would be very welcome!
Otherwise use Homebrew (see above) or read on for manual install instructions.
This will install
moor
into $GOPATH/bin
:
go install github.com/walles/moor@latest
NOTE: If you got here because there is no binary for your platform,
please consider packaging moor
.
- Download
moor
for your platform from https://github.com/walles/moor/releases/latest chmod a+x moor-*-*-*
sudo mv moor-*-*-* /usr/local/bin/moor
And now you can just invoke moor
from the prompt!
Try moor --help
to see options.
Do moor --help
for an up to date list of options.
Environment variable MOOR
can be used to set default options.
For example:
export MOOR='--statusbar=bold --no-linenumbers'
Set it as your default pager by adding...
export PAGER=/usr/local/bin/moor
... to your .bashrc
.
Issues are tracked here, or you can send questions to johan.walles@gmail.com.
If you package moor
, do include the man page in your package.
Here's one way to embed moor
in your app:
package main
import (
"github.com/walles/moor/pkg/moor"
)
func main() {
err := moor.PageFromString("Hello, world!", moor.Options{})
if err != nil {
// Handle paging problems
panic(err)
}
}
You can also PageFromStream()
or PageFromFile()
.
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/moor/internal && go tool pprof -alloc_objects -focus findFirstHit -relative_percentages -web profile.out
Build + run:
./moor.sh ...
Install (into /usr/local/bin
) from source:
./install.sh
Make sure that screenshot.png matches moor's current UI. If it doesn't, scale a window to 81x16 characters and make a new one.
Execute release.sh
and follow instructions.
-
Enable exiting using ^c (without restoring the screen).
-
Start at a certain line if run as
moor file.txt:42
-
Handle search hits to the right of the right screen edge. Searching forwards should move first right, then to the left edge and down. Searching backwards should move first left, then up and to the right edge (if needed for showing search hits).
-
Support viewing multiple files by pushing them in reverse order on the view stack.
-
Retain the search string when pressing / to search a second time.
-
Add
>
markers at the end of lines being cut because they are too long -
Doing moor on an arbitrary binary (like
/bin/ls
) should put all line-continuation markers at the rightmost column. This really means our truncation code must work even with things like tabs and various control characters. -
Make sure search hits are highlighted even when we have to scroll right to see them
-
Change out-of-file visualization to writing
---
after the end of the file and leaving the rest of the screen blank. -
Exit search on pressing up / down / pageup / pagedown keys and scroll. I attempted to do that spontaneously, so it's probably a good idea.
-
Remedy all FIXMEs in this README file
-
Release the
go
version as the newmoor
, replacing the previous Ruby implementation -
Add licensing information (same as for the Ruby branch)
-
Make sure
git grep
output gets highlighted properly. -
Handle all kinds of line endings.
-
Make sure version information is printed if there are warnings.
-
Add spinners while file is still loading
-
Make
tail -f /dev/null
exit properly, fix #7. -
Showing unicode search hits should highlight the correct chars
-
Arrow keys up / down while in line wrapping mode should scroll by screen line, not by input file line.
-
Define 'g' to prompt for a line number to go to.