Skip to content

Commit

Permalink
Allow tms to start without tmux open
Browse files Browse the repository at this point in the history
The switch-client command doesn't work when tmux isn't running.
If it fails, use the attach command instead to make tms usable
without having a tmux client open.
  • Loading branch information
Gawise authored and jaredmoulton committed May 9, 2023
1 parent 937d99e commit eec23c4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ fn main() -> Result<(), TmsError> {
set_up_tmux_env(found_repo, &repo_short_name)?;
}

execute_tmux_command(&format!("tmux switch-client -t {}", repo_short_name));
let result = execute_tmux_command(&format!("tmux switch-client -t {repo_short_name}"));
if !result.status.success() {
execute_tmux_command(&format!("tmux attach -t {repo_short_name}"));
}
Ok(())
}

Expand Down

0 comments on commit eec23c4

Please sign in to comment.