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). To keep the existing default behavior, added as a flag 'T' to select-window. Also updated the man-page for select-window to include the new flag 'T'.
Signed-off-by: Raghavendra D Prabhu <rpra...@wnohang.net> diff --git a/cmd-select-window.c b/cmd-select-window.c index 5d87e59..d62c1be 100644 --- a/cmd-select-window.c +++ b/cmd-select-window.c @@ -31,8 +31,8 @@ enum cmd_retval cmd_select_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_select_window_entry = { "select-window", "selectw", - "lnpt:", 0, 0, - "[-lnp] " CMD_TARGET_WINDOW_USAGE, + "lnpTt:", 0, 0, + "[-lnpT] " CMD_TARGET_WINDOW_USAGE, 0, cmd_select_window_key_binding, NULL, @@ -130,7 +130,17 @@ cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx) if (wl == NULL) return (CMD_RETURN_ERROR); - if (session_select(s, wl->idx) == 0) + /* + * If select-window is invoked on same window as current, switch + * to previous window + */ + if (args_has(self->args, 'T') && wl == s->curw) { + if (session_last(s) != 0) { + ctx->error(ctx, "no last window"); + return (-1); + } + server_redraw_session(s); + } else if (session_select(s, wl->idx) == 0) server_redraw_session(s); } recalculate_sizes(); diff --git a/tmux.1 b/tmux.1 index 213db74..20a61af 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1637,12 +1637,18 @@ is the same as using the .Ic last-pane command. .It Xo Ic select-window -.Op Fl lnp +.Op Fl lnpT .Op Fl t Ar target-window .Xc .D1 (alias: Ic selectw ) Select the window at .Ar target-window . +If invoked with +.Fl T +on same window as current window alongside +.Fl t, +it chooses last-window and +toggle betweens them in future runs. .Fl l , .Fl n and -- 1.8.0.2 ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users