diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2012-03-04 20:50:53 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2012-03-04 20:50:53 +0000 |
commit | 03dca66ae207e5b2d98a9cd337d472ea26bb95c6 (patch) | |
tree | 0d87f73acc1acad782211849fd4c97a061315ea2 /cmd-new-window.c | |
parent | 178a20718c007a254611d4f02c4c6f3ca7184d8d (diff) | |
download | rtmux-03dca66ae207e5b2d98a9cd337d472ea26bb95c6.tar.gz rtmux-03dca66ae207e5b2d98a9cd337d472ea26bb95c6.tar.bz2 rtmux-03dca66ae207e5b2d98a9cd337d472ea26bb95c6.zip |
Add -F format to new-window and split-window to use with the -P flag,
from George Nachman.
Diffstat (limited to 'cmd-new-window.c')
-rw-r--r-- | cmd-new-window.c | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/cmd-new-window.c b/cmd-new-window.c index cf93567d..2d409399 100644 --- a/cmd-new-window.c +++ b/cmd-new-window.c @@ -30,9 +30,9 @@ int cmd_new_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_new_window_entry = { "new-window", "neww", - "ac:dkn:Pt:", 0, 1, - "[-adk] [-c start-directory] [-n window-name] [-t target-window] " - "[command]", + "ac:dF:kn:Pt:", 0, 1, + "[-adkP] [-c start-directory] [-F format] [-n window-name] " + "[-t target-window] [command]", 0, NULL, NULL, @@ -42,12 +42,16 @@ const struct cmd_entry cmd_new_window_entry = { int cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) { - struct args *args = self->args; - struct session *s; - struct winlink *wl; - const char *cmd, *cwd; - char *cause; - int idx, last, detached; + struct args *args = self->args; + struct session *s; + struct winlink *wl; + struct client *c; + const char *cmd, *cwd; + const char *template; + char *cause; + int idx, last, detached; + struct format_tree *ft; + char *cp; if (args_has(args, 'a')) { wl = cmd_find_window(ctx, args_get(args, 't'), &s); @@ -116,7 +120,23 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) } else server_status_session_group(s); - if (args_has(args, 'P')) - ctx->print(ctx, "%s:%u", s->name, wl->idx); + if (args_has(args, 'P')) { + template = "#{session_name}:#{window_index}"; + if (args_has(args, 'F')) + template = args_get(args, 'F'); + + ft = format_create(); + if ((c = cmd_find_client(ctx, NULL)) != NULL) + format_client(ft, c); + format_session(ft, s); + format_winlink(ft, s, wl); + + cp = format_expand(ft, template); + ctx->print(ctx, "%s", cp); + free(cp); + + format_free(ft); + } + return (0); } |