oviewer

package module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2020 License: MIT Imports: 22 Imported by: 0

README

Oviewer

Actions Status Go Report Card

Oviewer is a feature rich terminal pager.

ov.png

feature

  • Better support for unicode and wide width.
  • Support for compressed files (gzip, bzip2, zstd, lz4, xz).
  • Supports column mode.
  • Header rows can be fixed.
  • Dynamic wrap / nowrap switchable.
  • Background color to alternate rows.

install

go get -u github.com/noborus/oviewer...

Usage

The command name of Oviewer is ov.

Oviewer supports open file name or standard input.

ov filename
cat filename|ov
$ ov --help
Oviewer is a feature rich pager(such as more/less).
It supports various compressed files(gzip, bzip2, zstd, lz4, and xz).

Usage:
  ov [flags]

Flags:
  -C, --alternate-rows            color to alternate rows
  -i, --case-sensitive            case-sensitive in search
  -d, --column-delimiter string   column delimiter (default ",")
  -c, --column-mode               column mode
      --config string             config file (default is $HOME/.oviewer.yaml)
      --debug                     debug mode
  -X, --exit-write                output the current screen when exiting
  -H, --header int                number of header rows to fix
  -h, --help                      help for ov
  -F, --quit-if-one-screen        quit if the output fits on one screen
  -x, --tab-width int             tab stop width (default 8)
  -v, --version                   display version information
  -w, --wrap                      wrap mode (default true)
wrap/nowrap toggle (w)

wrap/nowrap

column mode toggle (c)

column mode

color to alternate rows enable/disable toggle (C)

color enable/disable

number of header (H)

header

psql

Set environment variable PSQL_PAGER(PostgreSQL 11 or later).

export PSQL_PAGER='ov -w=f -H2 -F -C -d "|"'

You can also write in ~/.psqlrc in previous versions.

\setenv PAGER 'ov -w=f -H2 -F -C -d "|"'
mysql

Use the --pager option with the mysql client.

mysql --pager='ov -w=f -H3 -F -C -d "|"'

You can also write in ~/.my.cnf.

[client]
pager=ov -w=f -H3 -F -C -d "|"

Key bindings

  • q,Esc - quit
  • Q - output screen and quit
Move
  • HOME - go to begin of line

  • END - go to end of line

  • KEY_UP - backward by one line

  • KEY_DOWN, Enter - forward by one line

  • PgUP, Ctrl+b - backward by page

  • PgDn, Ctrl+v - forward by page

  • Ctrl+d - forward a half page

  • Ctrl+u - backward a half page

  • KEY_LEFT - scroll to left

  • KEY_RIGHT - scroll to right

  • Ctrl+KEY_LEFT - scroll to left page

  • Ctrl+KEY_RIGHT - scroll to right page

Mode
  • w - wrap/nowrap toggle
  • c - column mode enable/disable toggle
  • C - color to alternate rows enable/disable toggle
Input Mode
  • / - forward search mode
  • ? - previous search mode
  • H - number of header lines
  • g - number of go to line
  • d - delimiter string
Keys in search mode
  • Ctrl+a - case-sensitive/insensitive toggle
Key after search input mode
  • n - for next match
  • N - for next match in reverse direction

Documentation

Overview

Package oviewer provides a pager for terminals.

Index

Constants

This section is empty.

Variables

View Source
var Debug bool

Functions

func New

func New() *root

New returns the entire structure of oviewer.

Types

type Mode

type Mode int

type Model

type Model struct {
	// contains filtered or unexported fields
}

The Model structure contains the values for the logical screen.

func NewModel

func NewModel() *Model

NewModel returns Model.

func (*Model) BufEOF added in v0.0.5

func (m *Model) BufEOF() bool

BufEOF return reaching EOF.

func (*Model) BufEndNum added in v0.0.5

func (m *Model) BufEndNum() int

BuffEndNum return last line number.

func (*Model) BufLen added in v0.0.5

func (m *Model) BufLen() int

BufLen return buffer length.

func (*Model) ClearCache added in v0.0.5

func (m *Model) ClearCache()

ClearCache clears the cache.

func (*Model) GetContents added in v0.0.5

func (m *Model) GetContents(lineNum int, tabWidth int) []content

GetContents returns one line of contents from buffer.

func (*Model) GetLine added in v0.0.5

func (m *Model) GetLine(lineNum int) string

GetLine returns one line from buffer.

func (*Model) NewCache added in v0.0.5

func (m *Model) NewCache() error

NewCache creates a new cache.

func (*Model) ReadAll

func (m *Model) ReadAll(r io.Reader) error

ReadAll reads all from the reader to the buffer. It returns if beforeSize is accumulated in buffer before the end of read.

Directories

Path Synopsis
cmd
ov command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL