fzf

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding struct {
	// Keyboard shortcut, e.g. `ctrl-n`.
	Keys string
	// fzf action, see `man fzf`.
	Action string
	// Description which will be displayed as a fzf header if not empty.
	Description string
}

Binding represents a keyboard shortcut bound to an action in fzf.

type Fzf

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

Fzf filters a set of fields using fzf.

After adding all the fields with Add, use Selection to get the filtered results.

func New

func New(opts Opts) (*Fzf, error)

New runs a fzf instance.

To show a preview of each line, provide a previewCmd which will be executed by fzf.

func (*Fzf) Add

func (f *Fzf) Add(fields []string) error

Add appends a new line of fields to fzf input.

func (*Fzf) Selection

func (f *Fzf) Selection() ([][]string, error)

Selection returns the field lines selected by the user through fzf.

type NoteFinder

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

NoteFinder wraps a note.Finder and filters its result interactively using fzf.

func NewNoteFinder

func NewNoteFinder(opts NoteFinderOpts, finder note.Finder, terminal *term.Terminal) *NoteFinder

func (*NoteFinder) Find

func (f *NoteFinder) Find(opts note.FinderOpts) ([]note.Match, error)

type NoteFinderOpts

type NoteFinderOpts struct {
	// Indicates whether fzf is opened for every query, even if empty.
	AlwaysFilter bool
	// Preview command to run when selecting a note.
	PreviewCmd opt.String
	// When non nil, a "create new note from query" binding will be added to
	// fzf to create a note in this directory.
	NewNoteDir *zk.Dir
	// Absolute path to the notebook.
	BasePath string
	// Path to the working directory.
	CurrentPath string
}

NoteFinderOpts holds the configuration for the fzf notes finder.

The absolute path to the notebook (BasePath) and the working directory (CurrentPath) are used to make the path of each note relative to the working directory.

type Opts

type Opts struct {
	// Preview command executed by fzf when hovering a line.
	PreviewCmd opt.String
	// Amount of space between two non-empty fields.
	Padding int
	// Delimiter used by fzf between fields.
	Delimiter string
	// List of key bindings enabled in fzf.
	Bindings []Binding
}

Opts holds the options used to run fzf.

Jump to

Keyboard shortcuts

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