Search code examples
tmux

How to select a tmux window by name?


I have several windows including r-emr_task, r-emr_task_bake and r-emr_task_fry:

$ tmux list-windows | grep r-emr_task
0: r-emr_task (1 panes) [94x22] [layout 5685,94x22,0,0,54] @54
32: r-emr_task_fry (1 panes) [142x32] [layout 5976,142x32,0,0,55] @55
41: r-emr_task (1 panes) [142x32] [layout d971,142x32,0,0,41] @41
43: r-emr_task_bake (1 panes) [142x32] [layout d973,142x32,0,0,43] @43
45: r-emr_task_fry (1 panes) [142x32] [layout d975,142x32,0,0,45] @45
56: r-emr_task_bake (1 panes) [142x32] [layout d975,142x32,0,0,64] @64
$

If I try to switch to the r-emr_task window by using the ' command, and then entering r-emr_task, I get the error: Can't find window: r-emr_task.

So what I end up doing is using the " command and the /r-emr_task to search for the window and press ENTER to select it.

Why doesn't the ' command work? The tmux man page says:

   '           Prompt for a window index to select.

I've also tried ' followed by =r-emr_task to select exactly that window. I also tried =0:r-emr_task to include the session name. No go.


Solution

  • It's because you have two windows with the same name r-emr_task. C-b ' expects that the "index" matches only one window.

     0: r-emr_task (1 panes) [94x22]  [layout 5685,94x22,0,0,54]  @54
    41: r-emr_task (1 panes) [142x32] [layout d971,142x32,0,0,41] @41