diff options
author | 2013-03-25 11:44:00 +0000 | |
---|---|---|
committer | 2013-03-25 11:44:00 +0000 | |
commit | 15037bfc21bb9e8418e3eccd8ca8ea404e3f0f85 (patch) | |
tree | 120c223005ce89e71a204775eabe5a790a982ee6 | |
parent | Create a new context when copying instead of using the input (diff) | |
download | wireguard-openbsd-15037bfc21bb9e8418e3eccd8ca8ea404e3f0f85.tar.xz wireguard-openbsd-15037bfc21bb9e8418e3eccd8ca8ea404e3f0f85.zip |
Add -P and -F to new-session.
-rw-r--r-- | usr.bin/tmux/cmd-new-session.c | 52 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-new-window.c | 8 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 15 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 |
4 files changed, 52 insertions, 26 deletions
diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c index f62a74417a1..4b8aaef196f 100644 --- a/usr.bin/tmux/cmd-new-session.c +++ b/usr.bin/tmux/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-session.c,v 1.49 2013/03/24 09:58:40 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.50 2013/03/25 11:44:00 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,9 +35,9 @@ enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmd_q *); const struct cmd_entry cmd_new_session_entry = { "new-session", "new", - "AdDn:s:t:x:y:", 0, 1, - "[-AdD] [-n window-name] [-s session-name] " CMD_TARGET_SESSION_USAGE - " [-x width] [-y height] [command]", + "AdDF:n:Ps:t:x:y:", 0, 1, + "[-AdDP] [-F format] [-n window-name] [-s session-name] " + CMD_TARGET_SESSION_USAGE " [-x width] [-y height] [command]", CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON, NULL, cmd_new_session_check, @@ -55,19 +55,20 @@ cmd_new_session_check(struct args *args) enum cmd_retval cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) { - struct args *args = self->args; - struct client *c = cmdq->client; - struct session *s, *groupwith; - struct window *w; - struct environ env; - struct termios tio, *tiop; - struct passwd *pw; - const char *newname, *target, *update, *cwd, *errstr; - char *cmd, *cause; - int detached, idx; - u_int sx, sy; - int already_attached; - + struct args *args = self->args; + struct client *c = cmdq->client; + struct session *s, *groupwith; + struct window *w; + struct environ env; + struct termios tio, *tiop; + struct passwd *pw; + const char *newname, *target, *update, *cwd, *errstr; + const char *template; + char *cmd, *cause, *cp; + int detached, idx; + u_int sx, sy; + int already_attached; + struct format_tree *ft; newname = args_get(args, 's'); if (newname != NULL) { @@ -233,6 +234,23 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) if (cfg_finished) cfg_show_causes(s); + /* Print if requested. */ + if (args_has(args, 'P')) { + if ((template = args_get(args, 'F')) == NULL) + template = NEW_SESSION_TEMPLATE; + + ft = format_create(); + if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL) + format_client(ft, c); + format_session(ft, s); + + cp = format_expand(ft, template); + cmdq_print(cmdq, "%s", cp); + free(cp); + + format_free(ft); + } + if (!detached) cmdq->client_exit = 0; return (CMD_RETURN_NORMAL); diff --git a/usr.bin/tmux/cmd-new-window.c b/usr.bin/tmux/cmd-new-window.c index 3c7bb3762b2..3d6bb2818b0 100644 --- a/usr.bin/tmux/cmd-new-window.c +++ b/usr.bin/tmux/cmd-new-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-window.c,v 1.31 2013/03/24 09:54:10 nicm Exp $ */ +/* $OpenBSD: cmd-new-window.c,v 1.32 2013/03/25 11:44:00 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -46,12 +46,10 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq) struct session *s; struct winlink *wl; struct client *c; - const char *cmd, *cwd; - const char *template; - char *cause; + const char *cmd, *cwd, *template; + char *cause, *cp; int idx, last, detached; struct format_tree *ft; - char *cp; if (args_has(args, 'a')) { wl = cmd_find_window(cmdq, args_get(args, 't'), &s); diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 55f05477b51..2aedefcd561 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.350 2013/03/25 11:40:40 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.351 2013/03/25 11:44:00 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -671,7 +671,8 @@ command. Lock all clients attached to .Ar target-session . .It Xo Ic new-session -.Op Fl AdD +.Op Fl AdDP +.Op Fl F Ar format .Op Fl n Ar window-name .Op Fl s Ar session-name .Op Fl t Ar target-session @@ -736,6 +737,14 @@ or are invalid if .Fl t is used. +.Pp +The +.Fl P +option prints information about the new session after it has been created. +By default, it uses the format +.Ql #{session_name}: +but a different format may be specified with +.Fl F . .It Xo Ic refresh-client .Op Fl S .Op Fl t Ar target-client @@ -1466,9 +1475,9 @@ option. .It Xo Ic new-window .Op Fl adkP .Op Fl c Ar start-directory +.Op Fl F Ar format .Op Fl n Ar window-name .Op Fl t Ar target-window -.Op Fl F Ar format .Op Ar shell-command .Xc .D1 (alias: Ic neww ) diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index ab46c3cedce..8358e5c76a4 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.405 2013/03/25 11:43:01 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.406 2013/03/25 11:44:00 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -159,6 +159,7 @@ extern char **environ; /* Default templates for break-pane, new-window and split-window. */ #define BREAK_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}" +#define NEW_SESSION_TEMPLATE "#{session_name}:" #define NEW_WINDOW_TEMPLATE BREAK_PANE_TEMPLATE #define SPLIT_WINDOW_TEMPLATE BREAK_PANE_TEMPLATE |