This is to simulate a behavior similar to what is found in window managers where
using the same key used to switched to the workspace returns to previous
workspace; since this allows faster switching (by making use of locality of the
key).

Signed-off-by: Raghavendra D Prabhu <rpra...@wnohang.net>
---
 cmd-select-window.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/cmd-select-window.c b/cmd-select-window.c
index 5d87e59..103fd5b 100644
--- a/cmd-select-window.c
+++ b/cmd-select-window.c
@@ -130,7 +130,20 @@ cmd_select_window_exec(struct cmd *self, struct cmd_ctx 
*ctx)
                if (wl == NULL)
                        return (CMD_RETURN_ERROR);
 
+               /*
+                * If select-window is invoked on same window as current, switch
+                * to previous window
+                */
+               if (wl == s->curw) {
+                       if (session_last(s) != 0) {
+                               ctx->error(ctx, "no last window");
+                               return (-1);
+                       }
+                       goto redraw;
+               }
+
                if (session_select(s, wl->idx) == 0)
+redraw:
                        server_redraw_session(s);
        }
        recalculate_sizes();
-- 
1.8.0


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to