Skip to content

Commit

Permalink
Attach to a session if switching fails (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmoulton authored Aug 18, 2024
1 parent a94fe14 commit 6e74e43
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/tmux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,12 @@ impl Tmux {
}

pub fn switch_client(&self, session_name: &str) -> process::Output {
self.execute_tmux_command(&["switch-client", "-t", session_name])
let output = self.execute_tmux_command(&["switch-client", "-t", session_name]);
if !output.status.success() {
self.execute_tmux_command(&["attach-session", "-t", session_name])
} else {
output
}
}

pub fn display_message(&self, format: &str) -> String {
Expand Down

0 comments on commit 6e74e43

Please sign in to comment.