diff --git a/Cargo.lock b/Cargo.lock index fa58dd8db..6fb85bfdf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6431,6 +6431,7 @@ dependencies = [ "env-bootstrap", "filedescriptor", "hostname", + "humantime", "image", "libc", "log", diff --git a/wezterm/Cargo.toml b/wezterm/Cargo.toml index 7f296377e..64e6224bd 100644 --- a/wezterm/Cargo.toml +++ b/wezterm/Cargo.toml @@ -17,6 +17,7 @@ config = { path = "../config" } env-bootstrap = { path = "../env-bootstrap" } filedescriptor = { version="0.8", path = "../filedescriptor" } hostname = "0.4" +humantime = "2.1" image = "0.25" libc = "0.2" log = "0.4" diff --git a/wezterm/src/cli/list_clients.rs b/wezterm/src/cli/list_clients.rs index d92de5688..5697d07f2 100644 --- a/wezterm/src/cli/list_clients.rs +++ b/wezterm/src/cli/list_clients.rs @@ -67,7 +67,20 @@ impl ListClientsCommand { fn duration_string(d: chrono::Duration) -> String { if let Ok(d) = d.to_std() { - format!("{:?}", d) + // The default is full precision, which is a bit + // overwhelming (https://github.com/tailhook/humantime/issues/35). + // Let's auto-adjust this to be a bit more reasonable. + use std::time::Duration; + + let seconds = d.as_secs(); + let adjusted = if seconds >= 60 { + Duration::from_secs(seconds) + } else { + Duration::from_millis(d.as_millis() as u64) + }; + let mut formatted = humantime::format_duration(adjusted).to_string(); + formatted.retain(|c| c != ' '); + formatted } else { d.to_string() } @@ -114,6 +127,7 @@ struct CliListClientsResultItem { idle_time: std::time::Duration, workspace: String, focused_pane_id: Option, + ssh_auth_sock: Option, } impl From for CliListClientsResultItem { @@ -133,6 +147,7 @@ impl From for CliListClientsResultItem { username, hostname, pid, + ssh_auth_sock, .. } = client_id.as_ref(); @@ -148,7 +163,8 @@ impl From for CliListClientsResultItem { .unwrap_or(std::time::Duration::ZERO), idle_time: idle_time.to_std().unwrap_or(std::time::Duration::ZERO), workspace: active_workspace.as_deref().unwrap_or("").to_string(), - focused_pane_id: focused_pane_id, + focused_pane_id, + ssh_auth_sock: ssh_auth_sock.as_ref().map(|s| s.to_string()), } } }