From d5d8102f9f4169505e021143b9073871830f275a Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Fri, 6 Feb 2026 09:08:16 -0600 Subject: [PATCH] feat: add ssh-agent-socket subcommand to print socket path Makes it easy to set SSH_AUTH_SOCK on any platform, especially macOS where the path is non-obvious. --- src/bin/rbw/commands.rs | 4 ++++ src/bin/rbw/main.rs | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs index bddf0ef..1467ea1 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -1948,6 +1948,10 @@ pub fn purge() -> anyhow::Result<()> { Ok(()) } +pub fn ssh_agent_socket() { + println!("{}", rbw::dirs::ssh_agent_socket_file().display()); +} + pub fn stop_agent() -> anyhow::Result<()> { crate::actions::quit()?; diff --git a/src/bin/rbw/main.rs b/src/bin/rbw/main.rs index ff2ec74..2aef5a9 100644 --- a/src/bin/rbw/main.rs +++ b/src/bin/rbw/main.rs @@ -229,6 +229,12 @@ enum Opt { #[command(about = "Remove the local copy of the password database")] Purge, + #[command( + name = "ssh-agent-socket", + about = "Print the path to the SSH agent socket" + )] + SshAgentSocket, + #[command(name = "stop-agent", about = "Terminate the background agent")] StopAgent, @@ -261,6 +267,7 @@ impl Opt { Self::History { .. } => "history".to_string(), Self::Lock => "lock".to_string(), Self::Purge => "purge".to_string(), + Self::SshAgentSocket => "ssh-agent-socket".to_string(), Self::StopAgent => "stop-agent".to_string(), Self::GenCompletions { .. } => "gen-completions".to_string(), } @@ -448,6 +455,10 @@ fn main() { find_args.folder.as_deref(), find_args.ignorecase, ), + Opt::SshAgentSocket => { + commands::ssh_agent_socket(); + Ok(()) + } Opt::Lock => commands::lock(), Opt::Purge => commands::purge(), Opt::StopAgent => commands::stop_agent(),