diff options
Diffstat (limited to 'src/tmux.rs')
-rw-r--r-- | src/tmux.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/tmux.rs b/src/tmux.rs index 559242b..6993c2c 100644 --- a/src/tmux.rs +++ b/src/tmux.rs @@ -24,6 +24,21 @@ impl Tmux { .collect()) } + pub fn attached() -> Result<PathBuf, Error> { + let stdout = Command::new("tmux") + .arg("display") + .arg("-p") + .arg("#{session_path}") + .output()? + .stdout; + + std::str::from_utf8(&stdout)? + .lines() + .map(Into::into) + .last() + .ok_or(Error::NotFound) + } + pub fn get_session(&self, path_buf: PathBuf) -> Result<Project, Error> { let mut filter = OsString::from("#{==:#{session_path},"); filter.push(path_buf.as_os_str()); |