Hi,

I was trying to figure out if there is a way to select a window by its
name programmatically.  Specifically, I want a shell script that does
the following

#!/bin/sh

window=$1

if <some command to determine if the named window exists> ; then
  <some command to connect to window>
else
  tmux new-window -n $window
fi

It seems like for the first command, I can use tmux list-windows with a
format which includes window name like this

window_id=`tmux list-windows -F "#{window_index} #{window_name}" | grep $window 
|
cut -f 1`
if test -n "$window_id" ; then
  <some command to connect to window>
else
  tmux new-window -n $window
fi

But I still don't know if there's away to switch to a window by id.  The
closest command I can find is select-window but that seems to only allow
selection by last, next and previous.

I also see find-window which seems like what I would want but it needs
to be run interactively and I'd like to do this with a script.

Thanks,

-Anthony

-- 
------------------------------------------------------------------------
Anthony Molinaro                           <antho...@alumni.caltech.edu>

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to