Skip to content

Commit

Permalink
Use the index to select a new window
Browse files Browse the repository at this point in the history
Prepend window names with the index to handle windows with the same name
when selecting a new window.

Fixes #97
  • Loading branch information
petersimonsson committed May 9, 2024
1 parent fc95572 commit 93ecb69
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ fn switch_command(config: Config, tmux: &Tmux) -> Result<()> {
}

fn windows_command(config: Config, tmux: &Tmux) -> Result<()> {
let windows = tmux.list_windows("'#{?window_attached,,#{window_name}}'", None);
let windows = tmux.list_windows(
"'#{?window_attached,,#{window_index} #{window_name}}'",
None,
);

let windows: Vec<String> = windows
.replace('\'', "")
Expand All @@ -275,7 +278,9 @@ fn windows_command(config: Config, tmux: &Tmux) -> Result<()> {
config.shortcuts,
tmux.clone(),
)? {
tmux.select_window(&target_window.replace('.', "_"));
if let Some((windex, _)) = target_window.split_once(' ') {
tmux.select_window(windex);
}
}
Ok(())
}
Expand Down

0 comments on commit 93ecb69

Please sign in to comment.