page

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

🌳 Go Bonzai system pager detection

Just grabs the pager from the system and makes a new temporary file to page it. Eventual home of quick-n-dirty minimal pager when no system pager is detected.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &Z.Cmd{
	Name:    `page`,
	Summary: `use system pager or backup`,
	MaxArgs: 1,
	Usage:   ` [FILE]`,
	Commands: []*Z.Cmd{
		help.Cmd,
	},

	Description: `
		The {{aka}} command detects if the current runtime environment
		has a page program of any kind (like {{cmd "less"}} or
		{{cmd "more"}}) and simply executes that instead, but if it cannot
		find a page it provides its own rudimentary one that attempts to
		read the dimensions of the terminal and properly page content.

		{{cmd .Name}} accepts a single optional argument for the file to
		page, but usually content is piped into standard input.

		{{cmd .Name}} depends on the {{pkg "term"}} package for paging.

		Avoid temptation to rename this to {{exe "pager"}} since that is
		a reserved executable name on all UNIX/Linux systems.

	`,

	Call: func(x *Z.Cmd, args ...string) error {
		if len(args) == 0 {
			return This(os.Stdin)
		}
		return File(args[0])
	},
}

Functions

func File

func File(path string) error

File looks up the system pager and passes the first argument to it.

func FindPager

func FindPager() string

FindPager returns a full path to a pager binary if it can find one on the system:

  • $PAGER
  • pager (in PATH)

If neither is found returns an empty string.

func FixEnv added in v0.1.1

func FixEnv()

FixEnv sets environment variables for different pagers to get them to support color ANSI escapes. FRX is added to LESS and LV is set to -c. (These are the same fixes used by the git diff command.)

func This

func This[T any](buf T) error

Page pipes the buf as input to the system pager. Anything that to.String accepts can be passed.

Types

This section is empty.

Directories

Path Synopsis
cmd
page command

Jump to

Keyboard shortcuts

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