diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-10-10 12:07:38 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-10-10 12:07:38 +0000 |
commit | 99d716822f50f85e7f0ca74a388664b6bf8ec092 (patch) | |
tree | cfc445574805f0718d68e9bef7c019f142012693 /usr.bin/tmux/cmd-new-session.c | |
parent | 320f9ed40bfa191ac7bd7bf6de77c701f2b59034 (diff) |
Support -c for new-session, based on code from J Raynor.
Diffstat (limited to 'usr.bin/tmux/cmd-new-session.c')
-rw-r--r-- | usr.bin/tmux/cmd-new-session.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c index 869b7fbb7b0..0576806e203 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.51 2013/10/10 12:00:21 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.52 2013/10/10 12:07:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -34,9 +34,10 @@ enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmd_q *); const struct cmd_entry cmd_new_session_entry = { "new-session", "new", - "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]", + "Ac:dDF:n:Ps:t:x:y:", 0, 1, + "[-AdDP] [-c start-directory] [-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_exec @@ -52,8 +53,8 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) struct environ env; struct termios tio, *tiop; struct passwd *pw; - const char *newname, *target, *update, *cwd, *errstr; - const char *template; + const char *newname, *target, *update, *base, *cwd; + const char *errstr, *template; char *cmd, *cause, *cp; int detached, idx; u_int sx, sy; @@ -126,14 +127,19 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) /* Get the new session working directory. */ if (c != NULL && c->cwd != NULL) - cwd = c->cwd; + base = c->cwd; else { pw = getpwuid(getuid()); if (pw->pw_dir != NULL && *pw->pw_dir != '\0') - cwd = pw->pw_dir; + base = pw->pw_dir; else - cwd = "/"; + base = "/"; } + if (args_has(args, 'c')) + cwd = args_get(args, 'c'); + else + cwd = options_get_string(&global_s_options, "default-path"); + cwd = cmd_default_path(base, base, cwd); /* Find new session size. */ if (c != NULL) { |