mirror of
https://github.com/ddworken/hishtory.git
synced 2025-04-01 20:08:01 +02:00
Skip importing the existing shell history if install is ran and hishtory already has a significant number of history entries
This commit is contained in:
parent
49b81bcc19
commit
07bf84a4f9
17
hishtory.go
17
hishtory.go
@ -73,13 +73,18 @@ func main() {
|
||||
case "install":
|
||||
lib.CheckFatalError(lib.Install())
|
||||
if os.Getenv("HISHTORY_TEST") == "" {
|
||||
fmt.Println("Importing existing shell history...")
|
||||
ctx := hctx.MakeContext()
|
||||
// TODO: skip doing this if this is an update
|
||||
numImported, err := lib.ImportHistory(ctx, false)
|
||||
db, err := hctx.OpenLocalSqliteDb()
|
||||
lib.CheckFatalError(err)
|
||||
if numImported > 0 {
|
||||
fmt.Printf("Imported %v history entries from your existing shell history\n", numImported)
|
||||
data, err := data.Search(db, "", 10)
|
||||
lib.CheckFatalError(err)
|
||||
if len(data) < 10 {
|
||||
fmt.Println("Importing existing shell history...")
|
||||
ctx := hctx.MakeContext()
|
||||
numImported, err := lib.ImportHistory(ctx, false)
|
||||
lib.CheckFatalError(err)
|
||||
if numImported > 0 {
|
||||
fmt.Printf("Imported %v history entries from your existing shell history\n", numImported)
|
||||
}
|
||||
}
|
||||
}
|
||||
case "import":
|
||||
|
Loading…
Reference in New Issue
Block a user