mirror of
https://github.com/ddworken/hishtory.git
synced 2025-01-22 22:28:51 +01:00
Add a new field to the config for enabling control-r search and add undocumented commands to toggle this field from the CLI
This commit is contained in:
parent
37f351bb8a
commit
f337d7affd
@ -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) {
|
||||
|
26
hishtory.go
26
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()))
|
||||
|
Loading…
Reference in New Issue
Block a user