mirror of
https://github.com/ddworken/hishtory.git
synced 2025-04-10 10:38:21 +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":
|
case "install":
|
||||||
lib.CheckFatalError(lib.Install())
|
lib.CheckFatalError(lib.Install())
|
||||||
if os.Getenv("HISHTORY_TEST") == "" {
|
if os.Getenv("HISHTORY_TEST") == "" {
|
||||||
fmt.Println("Importing existing shell history...")
|
db, err := hctx.OpenLocalSqliteDb()
|
||||||
ctx := hctx.MakeContext()
|
|
||||||
// TODO: skip doing this if this is an update
|
|
||||||
numImported, err := lib.ImportHistory(ctx, false)
|
|
||||||
lib.CheckFatalError(err)
|
lib.CheckFatalError(err)
|
||||||
if numImported > 0 {
|
data, err := data.Search(db, "", 10)
|
||||||
fmt.Printf("Imported %v history entries from your existing shell history\n", numImported)
|
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":
|
case "import":
|
||||||
|
Loading…
Reference in New Issue
Block a user