update-environment, from Steven Lu.
-/* $OpenBSD: cmd-attach-session.c,v 1.35 2015/06/04 23:27:51 nicm Exp $ */
+/* $OpenBSD: cmd-attach-session.c,v 1.36 2015/06/07 21:39:39 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
const struct cmd_entry cmd_attach_session_entry = {
"attach-session", "attach",
- "c:drt:", 0, 0,
- "[-dr] [-c working-directory] " CMD_TARGET_SESSION_USAGE,
+ "c:dErt:", 0, 0,
+ "[-dEr] [-c working-directory] " CMD_TARGET_SESSION_USAGE,
CMD_STARTSERVER,
cmd_attach_session_exec
};
enum cmd_retval
cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
- const char *cflag)
+ const char *cflag, int Eflag)
{
struct session *s;
- struct client *c;
+ struct client *c = cmdq->client, *c_loop;
struct winlink *wl = NULL;
struct window *w = NULL;
struct window_pane *wp = NULL;
wl = winlink_find_by_window(&s->windows, w);
}
- if (cmdq->client == NULL)
+ if (c == NULL)
return (CMD_RETURN_NORMAL);
- if (server_client_check_nested(cmdq->client)) {
+ if (server_client_check_nested(c)) {
cmdq_error(cmdq, "sessions should be nested with care, "
"unset $TMUX to force");
return (CMD_RETURN_ERROR);
session_set_current(s, wl);
}
- if (cmdq->client->session != NULL) {
+ if (c->session != NULL) {
if (dflag) {
/*
* Can't use server_write_session in case attaching to
* the same session as currently attached to.
*/
- TAILQ_FOREACH(c, &clients, entry) {
- if (c->session != s || c == cmdq->client)
+ TAILQ_FOREACH(c_loop, &clients, entry) {
+ if (c_loop->session != s || c == c)
continue;
server_write_client(c, MSG_DETACH,
- c->session->name,
- strlen(c->session->name) + 1);
+ c_loop->session->name,
+ strlen(c_loop->session->name) + 1);
}
}
s->cwd = fd;
}
- cmdq->client->session = s;
- notify_attached_session_changed(cmdq->client);
+ c->session = s;
+ notify_attached_session_changed(c);
session_update_activity(s);
- server_redraw_client(cmdq->client);
+ server_redraw_client(c);
s->curw->flags &= ~WINLINK_ALERTFLAGS;
} else {
- if (server_client_open(cmdq->client, &cause) != 0) {
+ if (server_client_open(c, &cause) != 0) {
cmdq_error(cmdq, "open terminal failed: %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
if (rflag)
- cmdq->client->flags |= CLIENT_READONLY;
+ c->flags |= CLIENT_READONLY;
if (dflag) {
server_write_session(s, MSG_DETACH, s->name,
strlen(s->name) + 1);
}
- update = options_get_string(&s->options, "update-environment");
- environ_update(update, &cmdq->client->environ, &s->environ);
+ if (!Eflag) {
+ update = options_get_string(&s->options,
+ "update-environment");
+ environ_update(update, &c->environ, &s->environ);
+ }
- cmdq->client->session = s;
- notify_attached_session_changed(cmdq->client);
+ c->session = s;
+ notify_attached_session_changed(c);
session_update_activity(s);
- server_redraw_client(cmdq->client);
+ server_redraw_client(c);
s->curw->flags &= ~WINLINK_ALERTFLAGS;
- server_write_ready(cmdq->client);
+ server_write_ready(c);
cmdq->client_exit = 0;
}
recalculate_sizes();
struct args *args = self->args;
return (cmd_attach_session(cmdq, args_get(args, 't'),
- args_has(args, 'd'), args_has(args, 'r'), args_get(args, 'c')));
+ args_has(args, 'd'), args_has(args, 'r'), args_get(args, 'c'),
+ args_has(args, 'E')));
}
-/* $OpenBSD: cmd-new-session.c,v 1.67 2015/06/04 23:27:51 nicm Exp $ */
+/* $OpenBSD: cmd-new-session.c,v 1.68 2015/06/07 21:39:39 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
const struct cmd_entry cmd_new_session_entry = {
"new-session", "new",
- "Ac:dDF:n:Ps:t:x:y:", 0, -1,
- "[-AdDP] [-c start-directory] [-F format] [-n window-name] "
+ "Ac:dDEF:n:Ps:t:x:y:", 0, -1,
+ "[-AdDEP] [-c start-directory] [-F format] [-n window-name] "
"[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] "
"[-y height] [command]",
CMD_STARTSERVER,
if (session_find(newname) != NULL) {
if (args_has(args, 'A')) {
return (cmd_attach_session(cmdq, newname,
- args_has(args, 'D'), 0, NULL));
+ args_has(args, 'D'), 0, NULL,
+ args_has(args, 'E')));
}
cmdq_error(cmdq, "duplicate session: %s", newname);
return (CMD_RETURN_ERROR);
/* Construct the environment. */
environ_init(&env);
- update = options_get_string(&global_s_options, "update-environment");
- if (c != NULL)
+ if (c != NULL && !args_has(args, 'E')) {
+ update = options_get_string(&global_s_options,
+ "update-environment");
environ_update(update, &c->environ, &env);
+ }
/* Create the new session. */
idx = -1 - options_get_number(&global_s_options, "base-index");
-/* $OpenBSD: cmd-switch-client.c,v 1.25 2015/05/07 14:07:16 nicm Exp $ */
+/* $OpenBSD: cmd-switch-client.c,v 1.26 2015/06/07 21:39:39 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
const struct cmd_entry cmd_switch_client_entry = {
"switch-client", "switchc",
- "lc:npt:rT:", 0, 0,
- "[-lnpr] [-c target-client] [-t target-session] [-T key-table]",
+ "lc:Enpt:rT:", 0, 0,
+ "[-Elnpr] [-c target-client] [-t target-session] [-T key-table]",
CMD_READONLY,
cmd_switch_client_exec
};
}
}
- if (c != NULL && s != c->session) {
+ if (c != NULL && s != c->session && !args_has(args, 'E')) {
update = options_get_string(&s->options, "update-environment");
environ_update(update, &c->environ, &s->environ);
}
-.\" $OpenBSD: tmux.1,v 1.435 2015/06/05 08:14:16 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.436 2015/06/07 21:39:39 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 5 2015 $
+.Dd $Mdocdate: June 7 2015 $
.Dt TMUX 1
.Os
.Sh NAME
The following commands are available to manage clients and sessions:
.Bl -tag -width Ds
.It Xo Ic attach-session
-.Op Fl dr
+.Op Fl dEr
.Op Fl c Ar working-directory
.Op Fl t Ar target-session
.Xc
.Fl c
will set the session working directory (used for new windows) to
.Ar working-directory .
+.Pp
+If
+.Fl E
+is used,
+.Ic update-environment
+option will not be applied.
.It Xo Ic detach-client
.Op Fl P
.Op Fl a
Lock all clients attached to
.Ar target-session .
.It Xo Ic new-session
-.Op Fl AdDP
+.Op Fl AdDEP
.Op Fl c Ar start-directory
.Op Fl F Ar format
.Op Fl n Ar window-name
.Ql #{session_name}:
but a different format may be specified with
.Fl F .
+.Pp
+If
+.Fl E
+is used,
+.Ic update-environment
+option will not be applied.
+.Ic update-environment .
.It Xo Ic refresh-client
.Op Fl S
.Op Fl t Ar target-client
.Dv SIGTSTP
(tty stop).
.It Xo Ic switch-client
-.Op Fl lnpr
+.Op Fl Elnpr
.Op Fl c Ar target-client
.Op Fl t Ar target-session
.Op Fl T Ar key-table
.Ic attach-session
command).
.Pp
+If
+.Fl E
+is used,
+.Ic update-environment
+option will not be applied.
+.Pp
.Fl T
sets the client's key table; the next key from the client will be interpreted from
.Ar key-table .
-/* $OpenBSD: tmux.h,v 1.521 2015/06/05 22:33:39 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.522 2015/06/07 21:39:39 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
/* cmd-attach-session.c */
enum cmd_retval cmd_attach_session(struct cmd_q *, const char *, int, int,
- const char *);
+ const char *, int);
/* cmd-list.c */
struct cmd_list *cmd_list_parse(int, char **, const char *, u_int, char **);