new: history file location can now be set via BETTERCAP_HISTORY env var (closes #627)

This commit is contained in:
evilsocket 2024-08-09 17:27:06 +02:00
parent 9e7fda751a
commit 93de427f9a
2 changed files with 7 additions and 2 deletions

View file

@ -30,7 +30,8 @@ import (
)
const (
HistoryFile = "~/bettercap.history"
DefaultHistoryFile = "~/bettercap.history"
HistoryEnvVar = "BETTERCAP_HISTORY"
)
var (

View file

@ -72,7 +72,11 @@ func (s *Session) setupReadline() (err error) {
history := ""
if !*s.Options.NoHistory {
history, _ = fs.Expand(HistoryFile)
histPath := DefaultHistoryFile
if fromEnv := os.Getenv(HistoryEnvVar); fromEnv != "" {
histPath = fromEnv
}
history, _ = fs.Expand(histPath)
}
cfg := readline.Config{