summaryrefslogtreecommitdiffstats
path: root/cmd-new-window.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd-new-window.c')
-rw-r--r--cmd-new-window.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/cmd-new-window.c b/cmd-new-window.c
index 722f89b9..0b24474b 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -38,8 +38,8 @@ const struct cmd_entry cmd_new_window_entry = {
.name = "new-window",
.alias = "neww",
- .args = { "ac:de:F:kn:Pt:", 0, -1 },
- .usage = "[-adkP] [-c start-directory] [-e environment] [-F format] "
+ .args = { "abc:de:F:kn:Pt:", 0, -1 },
+ .usage = "[-abdkP] [-c start-directory] [-e environment] [-F format] "
"[-n window-name] " CMD_TARGET_WINDOW_USAGE " [command]",
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_WINDOW_INDEX },
@@ -58,16 +58,20 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
struct client *tc = cmdq_get_target_client(item);
struct session *s = target->s;
struct winlink *wl = target->wl;
- int idx = target->idx;
+ int idx = target->idx, before;
struct winlink *new_wl;
char *cause = NULL, *cp;
const char *template, *add;
struct cmd_find_state fs;
struct args_value *value;
- if (args_has(args, 'a') && (idx = winlink_shuffle_up(s, wl)) == -1) {
- cmdq_error(item, "couldn't get a window index");
- return (CMD_RETURN_ERROR);
+ before = args_has(args, 'b');
+ if (args_has(args, 'a') || before) {
+ idx = winlink_shuffle_up(s, wl, before);
+ if (idx == -1) {
+ cmdq_error(item, "couldn't get a window index");
+ return (CMD_RETURN_ERROR);
+ }
}
memset(&sc, 0, sizeof sc);