mirror of
https://github.com/tmate-io/tmate.git
synced 2025-02-02 19:39:32 +01:00
Add -P and -F to new-session.
This commit is contained in:
parent
0ccd84d2ef
commit
7f191c7951
@ -35,9 +35,9 @@ enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmd_q *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_new_session_entry = {
|
const struct cmd_entry cmd_new_session_entry = {
|
||||||
"new-session", "new",
|
"new-session", "new",
|
||||||
"AdDn:s:t:x:y:", 0, 1,
|
"AdDF:n:Ps:t:x:y:", 0, 1,
|
||||||
"[-AdD] [-n window-name] [-s session-name] " CMD_TARGET_SESSION_USAGE
|
"[-AdDP] [-F format] [-n window-name] [-s session-name] "
|
||||||
" [-x width] [-y height] [command]",
|
CMD_TARGET_SESSION_USAGE " [-x width] [-y height] [command]",
|
||||||
CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON,
|
CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_new_session_check,
|
cmd_new_session_check,
|
||||||
@ -63,11 +63,12 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
struct termios tio, *tiop;
|
struct termios tio, *tiop;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
const char *newname, *target, *update, *cwd, *errstr;
|
const char *newname, *target, *update, *cwd, *errstr;
|
||||||
char *cmd, *cause;
|
const char *template;
|
||||||
|
char *cmd, *cause, *cp;
|
||||||
int detached, idx;
|
int detached, idx;
|
||||||
u_int sx, sy;
|
u_int sx, sy;
|
||||||
int already_attached;
|
int already_attached;
|
||||||
|
struct format_tree *ft;
|
||||||
|
|
||||||
newname = args_get(args, 's');
|
newname = args_get(args, 's');
|
||||||
if (newname != NULL) {
|
if (newname != NULL) {
|
||||||
@ -233,6 +234,23 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
if (cfg_finished)
|
if (cfg_finished)
|
||||||
cfg_show_causes(s);
|
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)
|
if (!detached)
|
||||||
cmdq->client_exit = 0;
|
cmdq->client_exit = 0;
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
@ -46,12 +46,10 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
const char *cmd, *cwd;
|
const char *cmd, *cwd, *template;
|
||||||
const char *template;
|
char *cause, *cp;
|
||||||
char *cause;
|
|
||||||
int idx, last, detached;
|
int idx, last, detached;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
char *cp;
|
|
||||||
|
|
||||||
if (args_has(args, 'a')) {
|
if (args_has(args, 'a')) {
|
||||||
wl = cmd_find_window(cmdq, args_get(args, 't'), &s);
|
wl = cmd_find_window(cmdq, args_get(args, 't'), &s);
|
||||||
|
13
tmux.1
13
tmux.1
@ -675,7 +675,8 @@ command.
|
|||||||
Lock all clients attached to
|
Lock all clients attached to
|
||||||
.Ar target-session .
|
.Ar target-session .
|
||||||
.It Xo Ic new-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 n Ar window-name
|
||||||
.Op Fl s Ar session-name
|
.Op Fl s Ar session-name
|
||||||
.Op Fl t Ar target-session
|
.Op Fl t Ar target-session
|
||||||
@ -740,6 +741,14 @@ or
|
|||||||
are invalid if
|
are invalid if
|
||||||
.Fl t
|
.Fl t
|
||||||
is used.
|
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
|
.It Xo Ic refresh-client
|
||||||
.Op Fl S
|
.Op Fl S
|
||||||
.Op Fl t Ar target-client
|
.Op Fl t Ar target-client
|
||||||
@ -1470,9 +1479,9 @@ option.
|
|||||||
.It Xo Ic new-window
|
.It Xo Ic new-window
|
||||||
.Op Fl adkP
|
.Op Fl adkP
|
||||||
.Op Fl c Ar start-directory
|
.Op Fl c Ar start-directory
|
||||||
|
.Op Fl F Ar format
|
||||||
.Op Fl n Ar window-name
|
.Op Fl n Ar window-name
|
||||||
.Op Fl t Ar target-window
|
.Op Fl t Ar target-window
|
||||||
.Op Fl F Ar format
|
|
||||||
.Op Ar shell-command
|
.Op Ar shell-command
|
||||||
.Xc
|
.Xc
|
||||||
.D1 (alias: Ic neww )
|
.D1 (alias: Ic neww )
|
||||||
|
1
tmux.h
1
tmux.h
@ -155,6 +155,7 @@ extern char **environ;
|
|||||||
|
|
||||||
/* Default templates for break-pane, new-window and split-window. */
|
/* Default templates for break-pane, new-window and split-window. */
|
||||||
#define BREAK_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
|
#define BREAK_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
|
||||||
|
#define NEW_SESSION_TEMPLATE "#{session_name}:"
|
||||||
#define NEW_WINDOW_TEMPLATE BREAK_PANE_TEMPLATE
|
#define NEW_WINDOW_TEMPLATE BREAK_PANE_TEMPLATE
|
||||||
#define SPLIT_WINDOW_TEMPLATE BREAK_PANE_TEMPLATE
|
#define SPLIT_WINDOW_TEMPLATE BREAK_PANE_TEMPLATE
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user