version 1.49, 2013/03/24 09:58:40 |
version 1.50, 2013/03/25 11:44:00 |
|
|
|
|
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, |
|
|
enum cmd_retval |
enum cmd_retval |
cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) |
cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
struct client *c = cmdq->client; |
struct client *c = cmdq->client; |
struct session *s, *groupwith; |
struct session *s, *groupwith; |
struct window *w; |
struct window *w; |
struct environ env; |
struct environ env; |
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; |
int detached, idx; |
char *cmd, *cause, *cp; |
u_int sx, sy; |
int detached, idx; |
int already_attached; |
u_int sx, sy; |
|
int already_attached; |
|
struct format_tree *ft; |
|
|
|
|
newname = args_get(args, 's'); |
newname = args_get(args, 's'); |
if (newname != NULL) { |
if (newname != NULL) { |
if (!session_check_name(newname)) { |
if (!session_check_name(newname)) { |
|
|
*/ |
*/ |
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; |