2023-03-03 10:13:04 +03:00
|
|
|
[![Linux CI](https://github.com/walles/moar/actions/workflows/linux-ci.yml/badge.svg?branch=master)](https://github.com/walles/moar/actions/workflows/linux-ci.yml?query=branch%3Amaster)
|
|
|
|
[![Windows CI](https://github.com/walles/moar/actions/workflows/windows-ci.yml/badge.svg?branch=master)](https://github.com/walles/moar/actions/workflows/windows-ci.yml?query=branch%3Amaster)
|
2023-02-22 23:07:49 +03:00
|
|
|
|
2022-08-07 20:26:51 +03:00
|
|
|
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:
|
2019-06-08 23:12:52 +03:00
|
|
|
|
2019-08-04 08:57:09 +03:00
|
|
|
![Moar displaying its own source code](screenshot.png)
|
2019-06-08 23:12:52 +03:00
|
|
|
|
2022-03-13 00:31:52 +03:00
|
|
|
The intention is that Moar should be trivial to get into if you have previously
|
|
|
|
been using [Less](http://www.greenwoodsoftware.com/less/). If you come from Less
|
|
|
|
and find Moar confusing or hard to migrate to, [please report
|
|
|
|
it](https://github.com/walles/moar/issues)!
|
2019-06-08 23:12:52 +03:00
|
|
|
|
|
|
|
Doing the right thing includes:
|
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- **Syntax highlight** source code by default using
|
2021-01-09 19:18:10 +03:00
|
|
|
[Chroma](https://github.com/alecthomas/chroma)
|
2022-02-27 13:21:38 +03:00
|
|
|
- **Search is incremental** / find-as-you-type just like in
|
2019-06-08 23:12:52 +03:00
|
|
|
[Chrome](http://www.google.com/chrome) or
|
|
|
|
[Emacs](http://www.gnu.org/software/emacs/)
|
2022-02-27 13:21:38 +03:00
|
|
|
- Search becomes case sensitive if you add any UPPER CASE characters
|
2019-06-08 23:12:52 +03:00
|
|
|
to your search terms, just like in Emacs
|
2022-02-27 13:21:38 +03:00
|
|
|
- [Regexp](http://en.wikipedia.org/wiki/Regular_expression#Basic_concepts)
|
2019-06-08 23:12:52 +03:00
|
|
|
search if your search string is a valid regexp
|
2022-02-27 13:21:38 +03:00
|
|
|
- Supports displaying ANSI color coded texts (like the output from
|
2020-11-17 10:44:29 +03:00
|
|
|
`git diff` [| `riff`](https://github.com/walles/riff) for example)
|
2022-02-27 13:21:38 +03:00
|
|
|
- Supports UTF-8 input and output
|
2022-07-21 20:10:23 +03:00
|
|
|
- **Automatic decompression** when viewing [compressed text
|
|
|
|
files](https://github.com/walles/moar/issues/97#issuecomment-1191415680)
|
2024-01-08 23:25:15 +03:00
|
|
|
(`.gz`, `.bz2`, `.xz`, `.zst`, `.zstd`)
|
2022-02-27 13:21:38 +03:00
|
|
|
- The position in the file is always shown
|
|
|
|
- Supports **word wrapping** (on actual word boundaries) if requested using
|
2021-05-24 20:14:19 +03:00
|
|
|
`--wrap` or by pressing <kbd>w</kbd>
|
2022-11-30 10:35:03 +03:00
|
|
|
- [**Follows output** as long as you are on the last line](https://github.com/walles/moar/issues/108#issuecomment-1331743242),
|
|
|
|
just like `tail -f`
|
2023-05-03 20:59:41 +03:00
|
|
|
- Renders [terminal
|
|
|
|
hyperlinks](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda)
|
|
|
|
properly
|
2023-12-16 20:59:58 +03:00
|
|
|
- **Mouse Scrolling** works out of the box (but
|
|
|
|
[look here for tradeoffs](https://github.com/walles/moar/blob/master/MOUSE.md))
|
2019-06-08 23:12:52 +03:00
|
|
|
|
2020-11-17 10:44:29 +03:00
|
|
|
[For compatibility reasons](https://github.com/walles/moar/issues/14), `moar`
|
2022-12-31 19:00:49 +03:00
|
|
|
uses the formats declared in these environment variables if present:
|
2019-10-30 23:00:11 +03:00
|
|
|
|
2022-12-31 19:00:49 +03:00
|
|
|
- `LESS_TERMCAP_md`: Man page <b>bold</b>
|
|
|
|
- `LESS_TERMCAP_us`: Man page <u>underline</u>
|
|
|
|
- `LESS_TERMCAP_so`: [Status bar and search hits](https://github.com/walles/moar/issues/114)
|
2019-10-30 23:00:11 +03:00
|
|
|
|
2021-05-13 20:00:53 +03:00
|
|
|
For configurability reasons, `moar` reads extra command line options from the
|
|
|
|
`MOAR` environment variable.
|
|
|
|
|
2020-11-17 10:44:29 +03:00
|
|
|
Moar is used as the default pager by:
|
2019-10-30 23:00:11 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- [`px` / `ptop`](https://github.com/walles/px), `ps` and `top` for human beings
|
|
|
|
- [`riff`](https://github.com/walles/riff), a diff filter highlighting which line parts have changed
|
2019-06-08 23:12:52 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
# Installing
|
|
|
|
|
|
|
|
## Using [Homebrew](https://brew.sh/)
|
2021-06-05 12:10:31 +03:00
|
|
|
|
|
|
|
```sh
|
2021-06-12 09:47:24 +03:00
|
|
|
brew install moar
|
2021-06-05 12:10:31 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
Then whenever you want to upgrade to the latest release:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
brew upgrade
|
|
|
|
```
|
|
|
|
|
2022-07-29 09:24:33 +03:00
|
|
|
## Using [MacPorts](https://www.macports.org/)
|
|
|
|
|
|
|
|
```sh
|
|
|
|
sudo port install moar
|
|
|
|
```
|
|
|
|
|
|
|
|
More info [here](https://ports.macports.org/port/moar/).
|
|
|
|
|
2023-01-04 08:27:14 +03:00
|
|
|
## Using [Gentoo](https://gentoo.org/)
|
|
|
|
|
|
|
|
```sh
|
|
|
|
emerge --ask --verbose sys-apps/moar
|
|
|
|
```
|
|
|
|
|
|
|
|
More info [here](https://packages.gentoo.org/packages/sys-apps/moar).
|
|
|
|
|
2023-02-22 21:56:22 +03:00
|
|
|
## Using [Arch Linux](https://archlinux.org/)
|
|
|
|
|
|
|
|
```sh
|
2023-05-10 15:30:06 +03:00
|
|
|
yay -S moar
|
2023-02-22 21:56:22 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
More info [here](https://aur.archlinux.org/packages/moar-git).
|
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
## Manual Install
|
|
|
|
|
2019-08-04 20:12:43 +03:00
|
|
|
1. Download `moar` for your platform from
|
|
|
|
<https://github.com/walles/moar/releases/latest>
|
|
|
|
1. `chmod a+x moar-*-*-*`
|
2020-11-18 18:27:58 +03:00
|
|
|
1. `sudo mv moar-*-*-* /usr/local/bin/moar`
|
2019-06-08 23:12:52 +03:00
|
|
|
|
|
|
|
And now you can just invoke `moar` from the prompt!
|
|
|
|
|
2021-05-22 16:56:55 +03:00
|
|
|
Try `moar --help` to see options.
|
|
|
|
|
2019-08-04 20:12:43 +03:00
|
|
|
If a binary for your platform is not available, please
|
|
|
|
[file a ticket](https://github.com/walles/moar/releases) or contact
|
|
|
|
<johan.walles@gmail.com>.
|
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
## Debian / Ubuntu
|
2020-04-23 07:32:45 +03:00
|
|
|
|
|
|
|
[A Request for Packaging is open](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=944035),
|
|
|
|
please help!
|
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
# Configuring
|
|
|
|
|
|
|
|
Do `moar --help` for an up to date list of options.
|
|
|
|
|
|
|
|
Environment variable `MOAR` can be used to set default options.
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
export MOAR='--statusbar=bold --no-linenumbers'
|
|
|
|
```
|
|
|
|
|
|
|
|
## Setting `moar` as your default pager
|
2019-06-08 23:12:52 +03:00
|
|
|
|
|
|
|
Set it as your default pager by adding...
|
|
|
|
|
|
|
|
```bash
|
|
|
|
export PAGER=/usr/local/bin/moar
|
|
|
|
```
|
|
|
|
|
|
|
|
... to your `.bashrc`.
|
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
# Issues
|
2019-06-08 23:12:52 +03:00
|
|
|
|
|
|
|
Issues are tracked [here](https://github.com/walles/moar/issues), or
|
|
|
|
you can send questions to <johan.walles@gmail.com>.
|
|
|
|
|
2022-07-21 17:08:31 +03:00
|
|
|
# Packaging
|
|
|
|
|
|
|
|
If you package `moar`, do include [the man page](moar.1) in your package.
|
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
# Embedding
|
2020-12-28 21:27:25 +03:00
|
|
|
|
2020-12-30 00:57:44 +03:00
|
|
|
Here's one way to embed `moar` in your app:
|
2020-12-28 21:27:25 +03:00
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-12-30 00:57:44 +03:00
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
|
2020-12-28 21:27:25 +03:00
|
|
|
"github.com/walles/moar/m"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2021-04-17 21:00:59 +03:00
|
|
|
buf := new(bytes.Buffer)
|
|
|
|
for range [99]struct{}{} {
|
|
|
|
fmt.Fprintln(buf, "Moar")
|
|
|
|
}
|
2020-12-30 17:19:19 +03:00
|
|
|
|
2021-04-17 21:00:59 +03:00
|
|
|
err := m.NewPager(m.NewReaderFromStream("Moar", buf)).Page()
|
2020-12-30 17:19:19 +03:00
|
|
|
if err != nil {
|
|
|
|
// Handle paging problems
|
|
|
|
panic(err)
|
2020-12-28 21:27:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-04-17 21:00:59 +03:00
|
|
|
`m.Reader` can also be initialized using `NewReaderFromText()` or
|
2020-12-30 00:57:44 +03:00
|
|
|
`NewReaderFromFilename()`.
|
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
# Developing
|
2019-06-08 23:12:52 +03:00
|
|
|
|
2021-01-09 19:18:10 +03:00
|
|
|
You need the [go tools](https://golang.org/doc/install).
|
2019-06-19 08:13:05 +03:00
|
|
|
|
|
|
|
Run tests:
|
2019-06-09 08:47:55 +03:00
|
|
|
|
|
|
|
```bash
|
2019-06-19 08:13:05 +03:00
|
|
|
./test.sh
|
2019-06-09 08:47:55 +03:00
|
|
|
```
|
2019-06-08 23:12:52 +03:00
|
|
|
|
2023-07-08 10:53:11 +03:00
|
|
|
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).
|
|
|
|
|
2021-04-22 08:56:10 +03:00
|
|
|
Run microbenchmarks:
|
|
|
|
|
|
|
|
```bash
|
2022-10-30 01:28:08 +03:00
|
|
|
go test -benchmem -run='^$' -bench=. . ./...
|
2021-04-22 08:56:10 +03:00
|
|
|
```
|
|
|
|
|
2022-10-30 01:54:22 +03:00
|
|
|
Profiling `BenchmarkPlainTextSearch()`. Try replacing `-alloc_objects` with
|
|
|
|
`-alloc_space` or change the `-focus` function:
|
|
|
|
|
|
|
|
```bash
|
2022-11-05 00:19:22 +03:00
|
|
|
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
|
2022-10-30 01:54:22 +03:00
|
|
|
```
|
|
|
|
|
2019-06-19 08:13:05 +03:00
|
|
|
Build + run:
|
2019-06-09 19:42:25 +03:00
|
|
|
|
|
|
|
```bash
|
2019-06-19 08:13:05 +03:00
|
|
|
./moar.sh ...
|
2019-06-09 19:42:25 +03:00
|
|
|
```
|
|
|
|
|
2019-07-07 19:44:08 +03:00
|
|
|
Install (into `/usr/local/bin`) from source:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
./install.sh
|
|
|
|
```
|
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
# Making a new Release
|
2019-06-08 23:12:52 +03:00
|
|
|
|
2020-09-05 21:40:33 +03:00
|
|
|
Make sure that [screenshot.png](screenshot.png) matches moar's current UI.
|
|
|
|
If it doesn't, scale a window to 81x16 characters and make a new one.
|
|
|
|
|
2019-08-04 20:07:14 +03:00
|
|
|
Execute `release.sh` and follow instructions.
|
2019-06-08 23:12:52 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
# TODO
|
2019-06-09 08:47:55 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Enable exiting using ^c (without restoring the screen).
|
2019-06-08 23:12:52 +03:00
|
|
|
|
2022-04-24 09:29:42 +03:00
|
|
|
- Start at a certain line if run as `moar file.txt:42`
|
2019-06-08 23:12:52 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- 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).
|
2019-06-08 23:12:52 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Support viewing multiple files by pushing them in reverse order on the view
|
|
|
|
stack.
|
2019-06-08 23:12:52 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Retain the search string when pressing / to search a second time.
|
2019-06-08 23:12:52 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
## Done
|
2019-08-03 21:14:22 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Add `>` markers at the end of lines being cut because they are too long
|
2019-08-03 21:14:22 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Doing moar 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.
|
2019-08-04 00:21:40 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Make sure search hits are highlighted even when we have to scroll right
|
2019-08-04 00:21:40 +03:00
|
|
|
to see them
|
2019-08-04 08:15:35 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Change out-of-file visualization to writing `---` after the end of the file
|
|
|
|
and leaving the rest of the screen blank.
|
2019-08-04 08:40:26 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Exit search on pressing up / down / pageup / pagedown keys and
|
2019-08-04 08:40:26 +03:00
|
|
|
scroll. I attempted to do that spontaneously, so it's probably a
|
|
|
|
good idea.
|
2019-08-04 20:12:43 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Remedy all FIXMEs in this README file
|
2019-08-08 18:59:04 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Release the `go` version as the new `moar`, replacing the previous Ruby
|
2019-08-08 18:59:04 +03:00
|
|
|
implementation
|
2019-08-09 17:51:08 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Add licensing information (same as for the Ruby branch)
|
2019-08-09 17:51:08 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Make sure `git grep` output gets highlighted properly.
|
2019-08-09 17:51:08 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Handle all kinds of line endings.
|
2019-08-09 17:51:08 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Make sure version information is printed if there are warnings.
|
2019-10-16 07:21:12 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Add spinners while file is still loading
|
2019-10-30 00:05:42 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Make `tail -f /dev/null` exit properly, fix
|
2019-10-30 00:05:42 +03:00
|
|
|
<https://github.com/walles/moar/issues/7>.
|
2019-11-06 23:42:20 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- Showing unicode search hits should highlight the correct chars
|
2021-05-24 20:14:19 +03:00
|
|
|
|
2022-02-27 13:21:38 +03:00
|
|
|
- [Word wrap text rather than character wrap it](m/linewrapper.go).
|
2022-05-01 19:11:17 +03:00
|
|
|
|
|
|
|
- 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.
|