summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDieter Eickstaedt <eickstaedt@deicon.de>2023-09-17 20:30:13 +0200
committerGitHub <noreply@github.com>2023-09-17 19:30:13 +0100
commitebef5cdaf018f2bb03682eb516412ce4151297aa (patch)
treea1ba2031a4317e808226903f74316e7bcbd4eff9
parent15abf429842969e56598b1922a21693a7253f117 (diff)
feat(keyup): Configure SearchMode for KeyUp invocation #1216 (#1224)
* feat(keyup): Configure SearchMode for KeyUp invocation #1216 * docs: adjusted search mode documentation * feat: setting search mode on engine * chore: cargo fmt * chore: removed redundant field name
-rw-r--r--atuin-client/config.toml5
-rw-r--r--atuin-client/src/settings.rs1
-rw-r--r--atuin/src/command/client/search/interactive.rs12
-rw-r--r--docs/docs/config/config.md12
-rw-r--r--docs/docs/key-binding.md2
5 files changed, 28 insertions, 4 deletions
diff --git a/atuin-client/config.toml b/atuin-client/config.toml
index 8a219641..7fd07986 100644
--- a/atuin-client/config.toml
+++ b/atuin-client/config.toml
@@ -47,6 +47,11 @@
## leave unspecified to use same mode set in "filter_mode"
# filter_mode_shell_up_key_binding = "global"
+## which search mode to use when atuin is invoked from a shell up-key binding
+## the accepted values are identical to those of "search_mode"
+## leave unspecified to use same mode set in "search_mode"
+# search_mode_shell_up_key_binding = "fuzzy"
+
## which style to use
## possible values: auto, full, compact
# style = "auto"
diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs
index ebc1a372..e2d22e93 100644
--- a/atuin-client/src/settings.rs
+++ b/atuin-client/src/settings.rs
@@ -157,6 +157,7 @@ pub struct Settings {
pub search_mode: SearchMode,
pub filter_mode: FilterMode,
pub filter_mode_shell_up_key_binding: Option<FilterMode>,
+ pub search_mode_shell_up_key_binding: Option<SearchMode>,
pub shell_up_key_binding: bool,
pub inline_height: u16,
pub invert: bool,
diff --git a/atuin/src/command/client/search/interactive.rs b/atuin/src/command/client/search/interactive.rs
index 8c12b1fb..78fd53aa 100644
--- a/atuin/src/command/client/search/interactive.rs
+++ b/atuin/src/command/client/search/interactive.rs
@@ -614,13 +614,19 @@ pub async fn history(
let context = current_context();
let history_count = db.history_count().await?;
-
+ let search_mode = if settings.shell_up_key_binding {
+ settings
+ .search_mode_shell_up_key_binding
+ .unwrap_or(settings.search_mode)
+ } else {
+ settings.search_mode
+ };
let mut app = State {
history_count,
results_state: ListState::default(),
update_needed: None,
switched_search_mode: false,
- search_mode: settings.search_mode,
+ search_mode,
search: SearchState {
input,
filter_mode: if settings.workspaces && context.git_root.is_some() {
@@ -634,7 +640,7 @@ pub async fn history(
},
context,
},
- engine: engines::engine(settings.search_mode),
+ engine: engines::engine(search_mode),
results_len: 0,
};
diff --git a/docs/docs/config/config.md b/docs/docs/config/config.md
index 1f295334..5f54790c 100644
--- a/docs/docs/config/config.md
+++ b/docs/docs/config/config.md
@@ -154,6 +154,18 @@ Filter modes can still be toggled via ctrl-r
filter_mode = "host"
```
+### `search_mode_shell_up_key_binding`
+
+The default searchmode to use when searching and being invoked from a shell up-key binding.
+
+Accepts exactly the same options as `search_mode` above
+
+```
+search_mode_shell_up_key_binding = "fuzzy"
+```
+
+Defaults to the value specified for search_mode.
+
### `filter_mode_shell_up_key_binding`
The default filter to use when searching and being invoked from a shell up-key binding.
diff --git a/docs/docs/key-binding.md b/docs/docs/key-binding.md
index c3931977..fd295007 100644
--- a/docs/docs/key-binding.md
+++ b/docs/docs/key-binding.md
@@ -8,7 +8,7 @@ Atuin does not yet have full key binding customization, though we do allow some
## Custom up arrow filter mode
-It can be useful to use a different filter mode on the up arrow. For example, you could use ctrl-r for searching globally, but the up arrow for searching history from the current directory only.
+It can be useful to use a different filter or search mode on the up arrow. For example, you could use ctrl-r for searching globally, but the up arrow for searching history from the current directory only.
Set your config like this: