diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/main.rs b/src/main.rs index c32c246..9eaa978 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use anyhow::Context; use clap::Parser; -use sshr::{Config, HostName, Hosts, KnownHosts, Sessions, Stdout}; +use sshr::{Config, HostName, Hosts, KnownHosts, Sessions, Stdout, Tmux}; fn main() -> anyhow::Result<()> { let mut config = Config::parse(); @@ -14,8 +14,13 @@ fn main() -> anyhow::Result<()> { let mut sessions = Sessions::new(config.sessions); if config.enabled.localhost() { - let hostname = HostName::get().context("Failed to get hostname of localhost")?; - sessions.extend(hostname); + if config.enabled.tmux() { + let local_sessions = Tmux::local_session().context("Failed to get local sessions")?; + sessions.extend(local_sessions); + } else { + let hostname = HostName::get().context("Failed to get hostname of localhost")?; + sessions.extend(hostname); + } } if config.enabled.tmux() { @@ -38,20 +43,6 @@ fn main() -> anyhow::Result<()> { sessions.extend(hosts); } - if config.enabled.history() { - match config.history.read() { - Ok(h) => sessions.extend(h), - Err(err) if err.kind() == std::io::ErrorKind::NotFound => { - tracing::warn!("Skipping non-existant history file") - } - Err(err) => return Err(err).context("Failed to read history file"), - } - } - - if config.history.update { - sessions.write_sessions(config.history)?; - } - sessions .write_sessions(Stdout::new(config.stdio)) .context("Failed to write to stdout") |