aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-client
diff options
context:
space:
mode:
authorPatrick Decat <pdecat@gmail.com>2022-12-18 19:26:09 +0100
committerGitHub <noreply@github.com>2022-12-18 18:26:09 +0000
commited394afa82ef919937521e5ce72fc467cec203f9 (patch)
treebc7d078684089e71d0d96f22328c5c266ad22d28 /atuin-client
parentBump debian from bullseye-20221024-slim to bullseye-20221205-slim (#638) (diff)
downloadatuin-ed394afa82ef919937521e5ce72fc467cec203f9.zip
Allow overriding filter and search modes from CLI (#635)
* Allow overriding filter and search modes from CLI arguments * Use session filter mode for bash up key binding * We precisely do not want to add quotes here so that all arguments are properly passed * Add --shell-up-key-binding hidden command argument and filter_mode_shell_up_key_binding configuration option to allow customizing the filter mode used when atuin is invoked from a shell up-key binding * Correct up binding for zsh Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
Diffstat (limited to 'atuin-client')
-rw-r--r--atuin-client/Cargo.toml1
-rw-r--r--atuin-client/src/settings.rs9
2 files changed, 8 insertions, 2 deletions
diff --git a/atuin-client/Cargo.toml b/atuin-client/Cargo.toml
index bdd72a5a..a08926ce 100644
--- a/atuin-client/Cargo.toml
+++ b/atuin-client/Cargo.toml
@@ -27,6 +27,7 @@ atuin-common = { path = "../atuin-common", version = "12.0.0" }
log = "0.4"
chrono = { version = "0.4", features = ["serde"] }
+clap = { version = "4.0.18", features = ["derive"] }
eyre = "0.6"
directories = "4"
uuid = { version = "1.2", features = ["v4"] }
diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs
index 574ee3fa..379237c6 100644
--- a/atuin-client/src/settings.rs
+++ b/atuin-client/src/settings.rs
@@ -4,6 +4,7 @@ use std::{
};
use chrono::{prelude::*, Utc};
+use clap::ValueEnum;
use config::{Config, Environment, File as ConfigFile, FileFormat};
use eyre::{eyre, Context, Result};
use fs_err::{create_dir_all, File};
@@ -16,7 +17,7 @@ pub const LAST_SYNC_FILENAME: &str = "last_sync_time";
pub const LAST_VERSION_CHECK_FILENAME: &str = "last_version_check_time";
pub const LATEST_VERSION_FILENAME: &str = "latest_version";
-#[derive(Clone, Debug, Deserialize, Copy)]
+#[derive(Clone, Debug, Deserialize, Copy, ValueEnum)]
pub enum SearchMode {
#[serde(rename = "prefix")]
Prefix,
@@ -28,7 +29,7 @@ pub enum SearchMode {
Fuzzy,
}
-#[derive(Clone, Debug, Deserialize, Copy, PartialEq, Eq)]
+#[derive(Clone, Debug, Deserialize, Copy, PartialEq, Eq, ValueEnum)]
pub enum FilterMode {
#[serde(rename = "global")]
Global = 0,
@@ -108,6 +109,8 @@ pub struct Settings {
pub session_path: String,
pub search_mode: SearchMode,
pub filter_mode: FilterMode,
+ pub filter_mode_shell_up_key_binding: FilterMode,
+ pub shell_up_key_binding: bool,
pub exit_mode: ExitMode,
// This is automatically loaded when settings is created. Do not set in
// config! Keep secrets and settings apart.
@@ -288,6 +291,8 @@ impl Settings {
.set_default("sync_address", "https://api.atuin.sh")?
.set_default("search_mode", "fuzzy")?
.set_default("filter_mode", "global")?
+ .set_default("filter_mode_shell_up_key_binding", "global")?
+ .set_default("shell_up_key_binding", false)?
.set_default("exit_mode", "return-original")?
.set_default("session_token", "")?
.set_default("style", "auto")?