From 49b81bcc19c9251afcccf5750e53788e72762dcd Mon Sep 17 00:00:00 2001 From: David Dworken Date: Thu, 20 Oct 2022 23:39:56 -0700 Subject: [PATCH] Support control-r search for fish --- client/lib/config.fish | 15 +++++++++++++-- hishtory.go | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/client/lib/config.fish b/client/lib/config.fish index 4bf53bc..bfe43ee 100644 --- a/client/lib/config.fish +++ b/client/lib/config.fish @@ -19,5 +19,16 @@ end # TODO: support background commands, see https://github.com/fish-shell/fish-shell/issues/3894 -# TODO: control-r search is currently unsupported for fish -[ "$(hishtory config-get enable-control-r)" = true ] && echo "Sorry, hishtory does not currently support overriding control-r for fish" +function __hishtory_on_control_r + set -l tmp (mktemp -t fish.XXXXXX) + set -x init_query (commandline -b) + hishtory tquery $init_query > $tmp + set -l res $status + commandline -f repaint + if [ -s $tmp ] + commandline -r (cat $tmp) + end + rm -f $tmp +end + +[ "$(hishtory config-get enable-control-r)" = true ] && bind \cr __hishtory_on_control_r \ No newline at end of file diff --git a/hishtory.go b/hishtory.go index c247c83..8bd57fc 100644 --- a/hishtory.go +++ b/hishtory.go @@ -75,6 +75,7 @@ func main() { 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) lib.CheckFatalError(err) if numImported > 0 {