From: Thomas <tho...@xteddy.org> As with the neww command, this adds a -c option to specify the starting directory of the session. This means default-path '-' is honored correctly without the need to first cd to the directory and start the tmux session from there.
I personally don't care either way for this patch, but note that one of the side-effects I'm unsure of is using 'new -c /tmp' would start the initial window in '/tmp', regardless whether default-path has been set globally. This might be counter-intuitive. I did consider changing the way cmd_get_default_path() worked in terms of not worrying about sessions, but this isn't possible. Neither have I bothered defaulting to checking &global_s_options to peturb 'new -c' in case it's set. This comes up on IRC a lot. --- cmd-new-session.c | 13 +++++++++++-- tmux.1 | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd-new-session.c b/cmd-new-session.c index 4eebe63..65edb4f 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -35,8 +35,9 @@ 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] " + "Ac:dDF:n:Ps:t:x:y:", 0, 1, + "[-AdDP] [-F format] [-c start-directory] [-n window-name] " + "[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] [-y height] [command]", CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON, NULL, @@ -140,6 +141,14 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) cwd = "/"; } + /* The user-specified path always overrides anything else. Note that + * we take it verbatim since the special options that neww would + * usually use for default-path can't be used here since we haven't + * created the session yet. + */ + if (args_has(args, 'c')) + cwd = args_get(args, 'c'); + /* Find new session size. */ if (c != NULL) { sx = c->tty.sx; diff --git a/tmux.1 b/tmux.1 index f644587..5653b4f 100644 --- a/tmux.1 +++ b/tmux.1 @@ -674,6 +674,7 @@ Lock all clients attached to .It Xo Ic new-session .Op Fl AdDP .Op Fl F Ar format +.Op Fl c Ar start-directory .Op Fl n Ar window-name .Op Fl s Ar session-name .Op Fl t Ar target-session @@ -688,6 +689,8 @@ Create a new session with name The new session is attached to the current terminal unless .Fl d is given. +.Fl c +specifies the starting directory the session will use. .Ar window-name and .Ar shell-command -- 1.8.3.2 ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users