Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "filter_mode_list" configuration option #1655

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
Comment on lines +363 to +364
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that this might be wrong, the condition should be wrapped in a !(...) I guess.

I'll leave it this way until there's a decision whether this feature is desired or not. 😸

}

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