mirror of
https://github.com/tmux/tmux.git
synced 2025-01-13 03:48:51 +00:00
Sync OpenBSD patchset 167:
If there is a current session, use its default path and working directory for the initial window when creating a new session.
This commit is contained in:
parent
7174c76bf0
commit
a551ff2b1b
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-new-session.c,v 1.45 2009-07-18 11:06:09 nicm Exp $ */
|
/* $Id: cmd-new-session.c,v 1.46 2009-07-23 13:19:12 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -112,6 +112,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
{
|
{
|
||||||
struct cmd_new_session_data *data = self->data;
|
struct cmd_new_session_data *data = self->data;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
struct options *oo;
|
||||||
char *cmd, *cwd, *cause;
|
char *cmd, *cwd, *cause;
|
||||||
u_int sx, sy;
|
u_int sx, sy;
|
||||||
|
|
||||||
@ -149,6 +150,14 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the called from inside, use the source session for the default
|
||||||
|
* path and command.
|
||||||
|
*/
|
||||||
|
oo = &global_s_options;
|
||||||
|
if (ctx->cmdclient == NULL)
|
||||||
|
oo = &ctx->curclient->session->options;
|
||||||
|
|
||||||
/* Find new session size and options. */
|
/* Find new session size and options. */
|
||||||
if (data->flag_detached) {
|
if (data->flag_detached) {
|
||||||
sx = 80;
|
sx = 80;
|
||||||
@ -162,7 +171,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
sy = ctx->curclient->tty.sy;
|
sy = ctx->curclient->tty.sy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sy > 0 && options_get_number(&global_s_options, "status"))
|
if (sy > 0 && options_get_number(oo, "status"))
|
||||||
sy--;
|
sy--;
|
||||||
if (sx == 0)
|
if (sx == 0)
|
||||||
sx = 1;
|
sx = 1;
|
||||||
@ -171,11 +180,11 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
||||||
cwd = ctx->cmdclient->cwd;
|
cwd = ctx->cmdclient->cwd;
|
||||||
else
|
else
|
||||||
cwd = options_get_string(&global_s_options, "default-path");
|
cwd = options_get_string(oo, "default-path");
|
||||||
if (data->cmd != NULL)
|
if (data->cmd != NULL)
|
||||||
cmd = data->cmd;
|
cmd = data->cmd;
|
||||||
else
|
else
|
||||||
cmd = options_get_string(&global_s_options, "default-command");
|
cmd = options_get_string(oo, "default-command");
|
||||||
|
|
||||||
/* Create the new session. */
|
/* Create the new session. */
|
||||||
s = session_create(data->newname, cmd, cwd, sx, sy, &cause);
|
s = session_create(data->newname, cmd, cwd, sx, sy, &cause);
|
||||||
|
Loading…
Reference in New Issue
Block a user