history

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackupHistoryFileIfExists

func BackupHistoryFileIfExists(historyFile string) error

BackupHistoryFileIfExists creates a backup of the given history file in place with a .back suffix

func ConvertEntryToLine

func ConvertEntryToLine(entry Entry) string

ConvertEntryToLine is a reverse parse operation that converts an Entry to a line for the zsh_history file

func RestoreOldHistory

func RestoreOldHistory(historyFile string) error

RestoreOldHistory moves the backup back to the main historyFile

func WriteHistoryFile

func WriteHistoryFile(entries []Entry, historyFile string) error

WriteHistoryFile write the entries back to the history file (default ~/.zsh_history) and backs up the last one

Types

type Entry

type Entry struct {
	Timestamp uint64
	Machine   string
	Command   string
}

Entry is struct that holds values for a particular history line

func MergeHistory

func MergeHistory(entrySlices ...[]Entry) []Entry

MergeHistory combines to Entry slices and sorts them by timestamps

func NewEntry

func NewEntry(timestamp uint64, machine string, command string) Entry

NewEntry consturcts a new Entry

func ParseFile

func ParseFile(location string, machine string) ([]Entry, error)

ParseFile returns Entry objects from a given zsh_history file

func ParseLine

func ParseLine(line string) (Entry, error)

ParseLine parses a single line of text to an Entry Object

func SliceEntries

func SliceEntries(lastTS uint64, entries []Entry) []Entry

SliceEntries reduces the slice of entries to only include entries AFTER the given timestamp

Jump to

Keyboard shortcuts

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