diff options
author | Toby Vincent <tobyv@tobyvin.dev> | 2023-10-27 18:57:08 -0500 |
---|---|---|
committer | Toby Vincent <tobyv@tobyvin.dev> | 2023-10-27 18:57:50 -0500 |
commit | 539fd0f26c83064b748bbd040fdf27f302f27cb7 (patch) | |
tree | 6f1c2fd2f9b8ef14897f2c3b0f1b8b3e7aeb0816 /src/tmux.rs | |
parent | c0d77c1eadc1d0304369d6bc8107ac9843be93f0 (diff) |
feat: order localhost using tmux if enabled and remove historydevelop
Diffstat (limited to 'src/tmux.rs')
-rw-r--r-- | src/tmux.rs | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/tmux.rs b/src/tmux.rs index b1f1af2..b53c172 100644 --- a/src/tmux.rs +++ b/src/tmux.rs @@ -55,6 +55,29 @@ impl Tmux { .transpose()? .ok_or(Error::NotFound) } + + pub fn local_session() -> Result<Vec<Session>, Error> { + let hostname = hostname::get()?; + let stdout = Command::new("tmux") + .arg("-L") + .arg("default") + .arg("list-sessions") + .arg("-F") + .arg(Self::SESSION_FORMAT) + .output()? + .stdout; + + let sessions: Vec<Session> = std::str::from_utf8(&stdout)? + .lines() + .flat_map(ron::from_str) + .map(|mut s: Session| { + s.name = hostname.to_string_lossy().into(); + s + }) + .collect(); + + Ok(sessions) + } } #[cfg(test)] @@ -64,7 +87,6 @@ mod tests { const SOCKET: &str = "test"; #[test] - #[ignore] fn test_tmux_list() -> Result<(), Error> { let names = Vec::from(["test_1", "test_2", "test_3", "test_4"]); @@ -94,4 +116,10 @@ mod tests { Ok(()) } + + #[test] + fn test_host() -> Result<(), Error> { + let _local_session = Tmux::local_session()?; + Ok(()) + } } |