Skip to content

Commit

Permalink
Add "filter_mode_list" configuration option
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Beyer <[email protected]>
  • Loading branch information
matthiasbeyer committed Jan 30, 2024
1 parent 366b8ea commit 9b7d98d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
7 changes: 7 additions & 0 deletions atuin-client/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
## possible values: global, host, session, directory
# filter_mode = "global"

## List of filter modes and how to cycle them
## For example, setting this to ["session", "host", "global"] makes you only
## cycle through these three, with "session" being the default, "host" coming
## next and "global" being last.
## possible values: global, host, session, directory, workspace
# filter_mode_list = ["global", "host", "session", "directory", "workspace"]

## With workspace filtering enabled, Atuin will filter for commands executed
## in any directory within a git repository tree (default: false)
# workspaces = false
Expand Down
2 changes: 2 additions & 0 deletions atuin-client/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ pub struct Settings {
pub session_path: String,
pub search_mode: SearchMode,
pub filter_mode: FilterMode,
pub filter_mode_list: Vec<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,
Expand Down Expand Up @@ -493,6 +494,7 @@ impl Settings {
.set_default("sync_frequency", "10m")?
.set_default("search_mode", "fuzzy")?
.set_default("filter_mode", "global")?
.set_default("filter_mode_list", vec!["global", "host", "session", "directory", "workspace"])?
.set_default("style", "auto")?
.set_default("inline_height", 0)?
.set_default("show_preview", false)?
Expand Down
21 changes: 4 additions & 17 deletions atuin/src/command/client/search/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,23 +359,10 @@ impl State {
}
KeyCode::Char('u') if ctrl => self.search.input.clear(),
KeyCode::Char('r') if ctrl => {
let filter_modes = if settings.workspaces && self.search.context.git_root.is_some()
{
vec![
FilterMode::Global,
FilterMode::Host,
FilterMode::Session,
FilterMode::Directory,
FilterMode::Workspace,
]
} else {
vec![
FilterMode::Global,
FilterMode::Host,
FilterMode::Session,
FilterMode::Directory,
]
};
let mut filter_modes = settings.filter_mode_list.clone();
if settings.workspaces && self.search.context.git_root.is_some() {
filter_modes.retain(|fm| *fm != FilterMode::Workspace);
}

let i = self.search.filter_mode as usize;
let i = (i + 1) % filter_modes.len();
Expand Down

0 comments on commit 9b7d98d

Please sign in to comment.