diff --git a/atuin-client/src/api_client.rs b/atuin-client/src/api_client.rs index 5ea84b9..2510d19 100644 --- a/atuin-client/src/api_client.rs +++ b/atuin-client/src/api_client.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; use std::collections::HashSet; +use std::env; use chrono::Utc; use eyre::{bail, Result}; @@ -161,10 +162,13 @@ impl<'a> Client<'a> { host: Option, deleted: HashSet, ) -> Result> { - let host = match host { - None => hash_str(&format!("{}:{}", whoami::hostname(), whoami::username())), - Some(h) => h, - }; + let host = host.unwrap_or_else(|| { + hash_str(&format!( + "{}:{}", + env::var("ATUIN_HOST_NAME").unwrap_or_else(|_| whoami::hostname()), + env::var("ATUIN_HOST_USER").unwrap_or_else(|_| whoami::username()) + )) + }); let url = format!( "{}/sync/history?sync_ts={}&history_ts={}&host={}", diff --git a/atuin-client/src/database.rs b/atuin-client/src/database.rs index c4a9ddc..f7c063c 100644 --- a/atuin-client/src/database.rs +++ b/atuin-client/src/database.rs @@ -43,7 +43,11 @@ pub fn current_context() -> Context { eprintln!("ERROR: Failed to find $ATUIN_SESSION in the environment. Check that you have correctly set up your shell."); std::process::exit(1); }; - let hostname = format!("{}:{}", whoami::hostname(), whoami::username()); + let hostname = format!( + "{}:{}", + env::var("ATUIN_HOST_NAME").unwrap_or_else(|_| whoami::hostname()), + env::var("ATUIN_HOST_USER").unwrap_or_else(|_| whoami::username()) + ); let cwd = utils::get_current_dir(); Context { diff --git a/atuin-client/src/history.rs b/atuin-client/src/history.rs index bb50a02..05bfbf7 100644 --- a/atuin-client/src/history.rs +++ b/atuin-client/src/history.rs @@ -49,8 +49,13 @@ impl History { let session = session .or_else(|| env::var("ATUIN_SESSION").ok()) .unwrap_or_else(|| uuid_v7().as_simple().to_string()); - let hostname = - hostname.unwrap_or_else(|| format!("{}:{}", whoami::hostname(), whoami::username())); + let hostname = hostname.unwrap_or_else(|| { + format!( + "{}:{}", + env::var("ATUIN_HOST_NAME").unwrap_or_else(|_| whoami::hostname()), + env::var("ATUIN_HOST_USER").unwrap_or_else(|_| whoami::username()) + ) + }); Self { id: uuid_v7().as_simple().to_string(),