aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-client/src
diff options
context:
space:
mode:
authorLucas Trzesniewski <lucas.trzesniewski@gmail.com>2026-02-12 01:06:11 +0100
committerGitHub <noreply@github.com>2026-02-11 16:06:11 -0800
commit6076b6b36bf1faffee41e958acdfc0a00bf3ecc3 (patch)
treeae9c3e4458aabbfb09872d30488a4162a4e05ad4 /crates/atuin-client/src
parentchore: update changelog (diff)
downloadatuin-6076b6b36bf1faffee41e958acdfc0a00bf3ecc3.zip
feat: `switch-context` (#3149)
This PR lets you change the current search context to the one of the currently selected command, which lets you easily see the surrounding commands of its session. It adds the following: - `switch-context` and `clear-context` actions - A `has-context` condition - `CTX:` and `C>` prefixes to show we're in another context The `switch-context` behavior is as follows: - The selected command defines the new context - The filter mode is automatically switched to SESSION - The search input is cleared, which gives you a full overview of the other commands executed in the same session - The command which triggered this mode keeps being selected to get a clear overview - The filter mode can be changed to modes such as DIRECTORY, but not to GLOBAL or SESSION+ as IMO those would be confusing in this mode This lets you easily navigate between modes and commands the way you prefer, for instance by switching the context through selected commands or switching back to the default mode with the same key. This could certainly still be improved (the docs are missing for instance), and if you have any feedback I can change the behavior as you see fit. I can add the docs when you'll approve the new names. Closes #2784 ## Checks - [x] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle - [x] I have checked that there are no existing pull requests for the same thing --------- Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
Diffstat (limited to 'crates/atuin-client/src')
-rw-r--r--crates/atuin-client/src/database.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/atuin-client/src/database.rs b/crates/atuin-client/src/database.rs
index 28d6c0f0..7aa095f7 100644
--- a/crates/atuin-client/src/database.rs
+++ b/crates/atuin-client/src/database.rs
@@ -32,6 +32,7 @@ use super::{
settings::{FilterMode, SearchMode, Settings},
};
+#[derive(Clone)]
pub struct Context {
pub session: String,
pub cwd: String,
@@ -72,6 +73,18 @@ pub async fn current_context() -> eyre::Result<Context> {
})
}
+impl Context {
+ pub fn from_history(entry: &History) -> Self {
+ Context {
+ session: entry.session.to_string(),
+ cwd: entry.cwd.to_string(),
+ hostname: entry.hostname.to_string(),
+ host_id: String::new(),
+ git_root: utils::in_git_repo(entry.cwd.as_str()),
+ }
+ }
+}
+
fn get_session_start_time(session_id: &str) -> Option<i64> {
if let Ok(uuid) = Uuid::parse_str(session_id)
&& let Some(timestamp) = uuid.get_timestamp()