summaryrefslogtreecommitdiffstats
path: root/cmd-new-session.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-07-22 22:47:43 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-07-22 22:47:43 +0000
commit05b511f96aeede18a6cc9b7e1e1edb4bb4f70dd7 (patch)
tree62b0f08e513a590df8c736191a870c3fa3282095 /cmd-new-session.c
parentbb14c36a27d308281af32dfa2e2f9b25d9755537 (diff)
If there is a current session, use its default path and working directory for
the initial window when creating a new session.
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r--cmd-new-session.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c
index 53e752ac..b7dd95cb 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -112,6 +112,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_new_session_data *data = self->data;
struct session *s;
+ struct options *oo;
char *cmd, *cwd, *cause;
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. */
if (data->flag_detached) {
sx = 80;
@@ -162,7 +171,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
sy = ctx->curclient->tty.sy;
}
}
- if (sy > 0 && options_get_number(&global_s_options, "status"))
+ if (sy > 0 && options_get_number(oo, "status"))
sy--;
if (sx == 0)
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)
cwd = ctx->cmdclient->cwd;
else
- cwd = options_get_string(&global_s_options, "default-path");
+ cwd = options_get_string(oo, "default-path");
if (data->cmd != NULL)
cmd = data->cmd;
else
- cmd = options_get_string(&global_s_options, "default-command");
+ cmd = options_get_string(oo, "default-command");
/* Create the new session. */
s = session_create(data->newname, cmd, cwd, sx, sy, &cause);