Rich Enhanced Shell History - Contextual shell history for zsh and bash
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
resh/pkg/histlist/histlist.go

27 lines
541 B

package histlist
// Histlist is a deduplicated list of cmdLines
type Histlist struct {
// list of commands lines (deduplicated)
List []string
// lookup: cmdLine -> last index
LastIndex map[string]int
}
// New Histlist
func New() Histlist {
return Histlist{LastIndex: make(map[string]int)}
}
// Copy Histlist
func Copy(hl Histlist) Histlist {
newHl := New()
// copy list
newHl.List = make([]string, len(hl.List))
copy(newHl.List, hl.List)
// copy map
for k, v := range hl.LastIndex {
newHl.LastIndex[k] = v
}
return newHl
}