aboutsummaryrefslogtreecommitdiffstats
path: root/crates/client/src/command/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--crates/client/src/command/mod.rs86
1 files changed, 5 insertions, 81 deletions
diff --git a/crates/client/src/command/mod.rs b/crates/client/src/command/mod.rs
index 9a648254..2e51a1e2 100644
--- a/crates/client/src/command/mod.rs
+++ b/crates/client/src/command/mod.rs
@@ -15,10 +15,6 @@ pub(crate) enum AtuinCmd {
#[command(flatten)]
Client(client::Cmd),
- /// PTY proxy for atuin
- #[command(alias = "hex")]
- PtyProxy(crate::atuin_pty_proxy::PtyProxy),
-
/// Generate a UUID
Uuid,
@@ -41,17 +37,12 @@ impl AtuinCmd {
match self {
Self::Client(client) => client.run(),
- Self::PtyProxy(proxy) => {
- run_pty_proxy(proxy);
- Ok(())
- }
-
Self::Contributors => {
contributors::run();
Ok(())
}
Self::Uuid => {
- println!("{}", crate::atuin_common::utils::uuid_v7().as_simple());
+ println!("{}", turtle_common::utils::uuid_v7().as_simple());
Ok(())
}
Self::GenCompletions(gen_completions) => gen_completions.run(),
@@ -60,52 +51,6 @@ impl AtuinCmd {
}
#[cfg(unix)]
-fn run_pty_proxy(proxy: crate::atuin_pty_proxy::PtyProxy) {
- proxy.run(semantic_command_capture_sink());
-}
-
-#[cfg(unix)]
-fn semantic_command_capture_sink() -> Option<crate::atuin_pty_proxy::CommandCaptureSink> {
- use std::sync::mpsc;
- use std::time::Duration;
-
- if is_truthy_env("ATUIN_TERMINAL") {
- return None;
- }
-
- let settings = crate::atuin_client::settings::Settings::new().ok()?;
- let (tx, rx) = mpsc::sync_channel::<crate::atuin_pty_proxy::CommandCapture>(128);
-
- std::thread::spawn(move || {
- let Ok(runtime) = tokio::runtime::Builder::new_current_thread()
- .enable_all()
- .build()
- else {
- return;
- };
-
- while let Ok(first) = rx.recv() {
- let mut batch = vec![first];
-
- while batch.len() < 64 {
- match rx.recv_timeout(Duration::from_millis(25)) {
- Ok(capture) => batch.push(capture),
- Err(mpsc::RecvTimeoutError::Timeout | mpsc::RecvTimeoutError::Disconnected) => {
- break;
- }
- }
- }
-
- runtime.block_on(send_semantic_command_captures(&settings, batch));
- }
- });
-
- Some(Box::new(move |capture| {
- drop(tx.try_send(capture));
- }))
-}
-
-#[cfg(unix)]
#[inline]
fn is_truthy_env(name: &str) -> bool {
std::env::var(name)
@@ -113,29 +58,8 @@ fn is_truthy_env(name: &str) -> bool {
.as_ref()
.is_some_and(|value| !value.trim().is_empty() && value.trim() != "false")
}
-
-#[cfg(unix)]
-async fn send_semantic_command_captures(
- settings: &crate::atuin_client::settings::Settings,
- batch: Vec<crate::atuin_pty_proxy::CommandCapture>,
-) {
- use crate::atuin_daemon::generated;
-
- let captures = batch
- .into_iter()
- .map(|capture| generated::semantic::CommandCapture {
- prompt: capture.prompt,
- command: capture.command,
- output: capture.output,
- exit_code: capture.exit_code,
- history_id: capture.history_id,
- session_id: capture.session_id,
- output_truncated: capture.output_truncated,
- output_observed_bytes: capture.output_observed_bytes,
- })
- .collect();
-
- if let Ok(mut client) = crate::atuin_daemon::SemanticClient::from_settings(settings).await {
- drop(client.record_commands(captures).await);
- }
+pub(crate) fn current_session() -> Result<String> {
+ std::env::var("ATUIN_SESSION").map_err(|_| {
+ eyre::eyre!("Failed to find $ATUIN_SESSION in the environment. Check that you have correctly set up your shell.")
+ })
}