We could add a session_stack format, something like this:

Index: format.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/format.c,v
retrieving revision 1.130
diff -u -p -r1.130 format.c
--- format.c    21 Apr 2017 14:01:19 -0000      1.130
+++ format.c    26 Apr 2017 07:42:05 -0000
@@ -48,6 +48,8 @@ static void    format_cb_host_short(struct
 static void     format_cb_pid(struct format_tree *, struct format_entry *);
 static void     format_cb_session_alerts(struct format_tree *,
                     struct format_entry *);
+static void     format_cb_session_stack(struct format_tree *,
+                    struct format_entry *);
 static void     format_cb_window_layout(struct format_tree *,
                     struct format_entry *);
 static void     format_cb_window_visible_layout(struct format_tree *,
@@ -382,7 +384,7 @@ format_cb_session_alerts(struct format_t
 {
        struct session  *s = ft->s;
        struct winlink  *wl;
-       char             alerts[256], tmp[16];
+       char             alerts[1024], tmp[16];
 
        if (s == NULL)
                return;
@@ -406,6 +408,28 @@ format_cb_session_alerts(struct format_t
        fe->value = xstrdup(alerts);
 }
 
+/* Callback for session_stack. */
+static void
+format_cb_session_stack(struct format_tree *ft, struct format_entry *fe)
+{
+       struct session  *s = ft->s;
+       struct winlink  *wl;
+       char             result[1024], tmp[16];
+
+       if (s == NULL)
+               return;
+
+       xsnprintf(result, sizeof result, "%u", s->curw->idx);
+       TAILQ_FOREACH(wl, &s->lastw, sentry) {
+               xsnprintf(tmp, sizeof tmp, "%u", wl->idx);
+
+               if (*result != '\0')
+                       strlcat(result, ",", sizeof result);
+               strlcat(result, tmp, sizeof result);
+       }
+       fe->value = xstrdup(result);
+}
+
 /* Callback for window_layout. */
 static void
 format_cb_window_layout(struct format_tree *ft, struct format_entry *fe)
@@ -1156,6 +1180,7 @@ format_defaults_session(struct format_tr
        format_add(ft, "session_many_attached", "%d", s->attached > 1);
 
        format_add_cb(ft, "session_alerts", format_cb_session_alerts);
+       format_add_cb(ft, "session_stack", format_cb_session_stack);
 }
 
 /* Set default format keys for a client. */




On Wed, Apr 26, 2017 at 07:33:57AM +0000, Scott ROCHFORD wrote:
>    I have a LOT of windows open.  Often I want to toggle quickly between two
>    of them... but sometimes three, or more.  So I thought I'd write my own
>    key bindings to go to the last but one, or the last but two... (a l`a
>    alt-tab,tab,tab in Windows) but without a way to access the MRU window
>    list I don't know how to do so.  Can you think of something tricky?
> 
>     
> 
>    Regards,
> 
>     
> 
>    Scott
> 
>     
> 
>    P.S. apologies for duplicate emails Nicholas, forgot to CC the list.
> 
>     
> 
>    From: Nicholas Marriott [mailto:[email protected]]
>    Sent: Wednesday, 26 April 2017 16:37
>    To: Scott ROCHFORD <[email protected]>
>    Cc: tmux-users <[email protected]>
>    Subject: Re: Way to access tmux internal window stack?
> 
>     
> 
>    Hi
> 
>    There is no way to access it at the moment. What do you need to access it
>    for?
> 
>     
> 
>     
> 
>     
> 
>     
> 
>     
> 
>    On 26 Apr 2017 7:19 am, "Scott ROCHFORD" <[email protected]>
>    wrote:
> 
>      Hi,
> 
>       
> 
>      tmux appears to maintain an internal window stack (similar Windows MRU
>      alt-tab stack) in most-recently-used order.
> 
>       
> 
>      You can toggle between the top two windows on the stack using the
>      'last-window' command (default key binding prefix-l), however I can't
>      find a way to access anything lower in the stack until you close those
>      top windows.  Is there some way you can list the windows in internal
>      stack order?  Do I need to make a feature request for a stack-order
>      option to the 'list-windows' and 'select-window' commands perhaps?
> 
>       
> 
>      Regards,
> 
>      Scott
> 
>      --
>      You received this message because you are subscribed to the Google
>      Groups "tmux-users" group.
>      To unsubscribe from this group and stop receiving emails from it, send
>      an email to [email protected].
>      To post to this group, send email to [email protected].
>      For more options, visit https://groups.google.com/d/optout.
> 
>     

-- 
You received this message because you are subscribed to the Google Groups 
"tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to