quickjump

package
v0.0.0-...-9c55465 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusErr = iota
	StatusAdd // new add
	StatusRpt // repeat add
)
View Source
const (
	ShellBash = "bash"
	ShellZsh  = "zsh"
	ShellFish = "fish" // TODO
)

Variables

View Source
var JumpBashTpl = `` /* 1116-byte string literal not displayed */

JumpBashTpl is the bash template for quick jump

View Source
var JumpZshTpl = `` /* 1255-byte string literal not displayed */

JumpZshTpl is the zsh template for quick jump

ShellTplMap shell templates

Functions

func GenScript

func GenScript(shell, fnName string) (string, error)

GenScript generate the shell script for quick jump

func IsStatusAdd

func IsStatusAdd(st int) bool

IsStatusAdd check

func IsSupported

func IsSupported(name string) bool

IsSupported check shell name is supported

Types

type Metadata

type Metadata struct {
	Datetime string `json:"datetime"`
	LastPath string `json:"last_path"`
	PrevPath string `json:"prev_path"`

	NamedPaths map[string]string `json:"named_paths"`
	Histories  map[string]string `json:"histories"`
	// contains filtered or unexported fields
}

Metadata struct for quick jump

func NewMetadata

func NewMetadata() *Metadata

NewMetadata new metadata instance

func (*Metadata) AddHistory

func (m *Metadata) AddHistory(dirPath string) (string, bool)

AddHistory add history path

func (*Metadata) AddNamed

func (m *Metadata) AddNamed(name string, pathStr string) (ok bool)

AddNamed add named path

func (*Metadata) AddNamedPaths

func (m *Metadata) AddNamedPaths(pathMap map[string]string) (ok bool)

AddNamedPaths add named path

func (*Metadata) CheckOrMatch

func (m *Metadata) CheckOrMatch(keywords []string) string

CheckOrMatch path by input keywords(name,path,...)

func (*Metadata) CleanHistories

func (m *Metadata) CleanHistories() (ss []string)

CleanHistories refresh histories, remove invalid paths

func (*Metadata) FormatKeywords

func (m *Metadata) FormatKeywords(keywords []string) []string

FormatKeywords handle

func (*Metadata) Search

func (m *Metadata) Search(keywords []string, limit int, withName bool) []string

Search named paths and history paths

func (*Metadata) SearchByString

func (m *Metadata) SearchByString(keywords string, limit int, withName bool) []string

SearchByString search named paths and history paths

func (*Metadata) SearchHistory

func (m *Metadata) SearchHistory(keywords []string, limit int) []string

SearchHistory named paths

func (*Metadata) SearchNamed

func (m *Metadata) SearchNamed(keywords []string, limit int, withName bool) []string

SearchNamed named paths

type QuickJump

type QuickJump struct {
	*Metadata `json:"-"`
	common.PathResolver

	// DataDir is data dir for save metadata files.
	DataDir string `json:"data_dir"`
	// CheckExist check path is exists
	CheckExist bool `json:"check_exist"`
	// SlashPath if true, will replace the path separator to slash
	//
	// - Useful on Windows
	SlashPath bool `json:"slash_path"`
	// NamedPaths pre-define named paths
	NamedPaths map[string]string `json:"named_paths"`
	// contains filtered or unexported fields
}

QuickJump struct

func NewQuickJump

func NewQuickJump() *QuickJump

NewQuickJump new quick jump instance

func (*QuickJump) Datafile

func (j *QuickJump) Datafile() string

Datafile get data file path

func (*QuickJump) Init

func (j *QuickJump) Init() error

Init load data from file

func (*QuickJump) Save

func (j *QuickJump) Save() error

Save data to disk

Jump to

Keyboard shortcuts

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