diff --git a/client/hctx/hctx.go b/client/hctx/hctx.go index d6a9918..878c4f7 100644 --- a/client/hctx/hctx.go +++ b/client/hctx/hctx.go @@ -154,6 +154,8 @@ type ClientConfig struct { MissedUploadTimestamp int64 `json:"missed_upload_timestamp"` // Used for avoiding double imports of .bash_history HaveCompletedInitialImport bool `json:"have_completed_initial_import"` + // Whether control-r bindings are enabled + ControlRSearchEnabled bool `json:"enable_control_r_search"` } func GetConfig() (ClientConfig, error) { diff --git a/hishtory.go b/hishtory.go index 747b3b1..e4b202e 100644 --- a/hishtory.go +++ b/hishtory.go @@ -111,6 +111,32 @@ func main() { if err != nil { log.Fatalf("Failed to update hishtory: %v", err) } + case "config-get": + // TODO: tests for config-get and config-set + ctx := hctx.MakeContext() + config := hctx.GetConf(ctx) + key := os.Args[2] + switch key { + case "enable-control-r": + fmt.Printf("%v", config.ControlRSearchEnabled) + default: + log.Fatalf("Unrecognized config key: %s", key) + } + case "config-set": + ctx := hctx.MakeContext() + config := hctx.GetConf(ctx) + key := os.Args[2] + val := os.Args[3] + switch key { + case "enable-control-r": + if val != "true" && val != "false" { + log.Fatalf("Unexpected config value %s, must be one of: true, false", val) + } + config.ControlRSearchEnabled = (val == "true") + lib.CheckFatalError(hctx.SetConfig(config)) + default: + log.Fatalf("Unrecognized config key: %s", key) + } case "reupload": // Purposefully undocumented since this command is generally not necessary to run lib.CheckFatalError(lib.Reupload(hctx.MakeContext()))