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/cmd/evaluate/strategy-recent.go

32 lines
720 B

package main
import "github.com/curusarn/resh/pkg/records"
type strategyRecent struct {
history []string
}
func (s *strategyRecent) GetTitleAndDescription() (string, string) {
return "recent", "Use recent commands"
}
func (s *strategyRecent) GetCandidates() []string {
return s.history
}
func (s *strategyRecent) AddHistoryRecord(record *records.EnrichedRecord) error {
// remove previous occurance of record
for i, cmd := range s.history {
if cmd == record.CmdLine {
s.history = append(s.history[:i], s.history[i+1:]...)
}
}
// append new record
s.history = append([]string{record.CmdLine}, s.history...)
return nil
}
func (s *strategyRecent) ResetHistory() error {
s.history = nil
return nil
}