diff options
author | 2013-03-24 09:58:40 +0000 | |
---|---|---|
committer | 2013-03-24 09:58:40 +0000 | |
commit | eb088ac5775e56b5f2e77bfa03a7d40a925978fa (patch) | |
tree | 9e3e467efdb5dbf05ad4cf1fbd50d3b6b76897ab /usr.bin/tmux/cmd-attach-session.c | |
parent | Add resize-pane -Z to temporary zoom the active pane to occupy the full (diff) | |
download | wireguard-openbsd-eb088ac5775e56b5f2e77bfa03a7d40a925978fa.tar.xz wireguard-openbsd-eb088ac5775e56b5f2e77bfa03a7d40a925978fa.zip |
Add -A flag to new-session to make it behave like attach-session if the
session exists. If -A is used, -D behaves like -d to attach-session.
Diffstat (limited to 'usr.bin/tmux/cmd-attach-session.c')
-rw-r--r-- | usr.bin/tmux/cmd-attach-session.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/usr.bin/tmux/cmd-attach-session.c b/usr.bin/tmux/cmd-attach-session.c index c5aee1ecd9f..412bd883196 100644 --- a/usr.bin/tmux/cmd-attach-session.c +++ b/usr.bin/tmux/cmd-attach-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-attach-session.c,v 1.23 2013/03/24 09:54:10 nicm Exp $ */ +/* $OpenBSD: cmd-attach-session.c,v 1.24 2013/03/24 09:58:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -39,9 +39,8 @@ const struct cmd_entry cmd_attach_session_entry = { }; enum cmd_retval -cmd_attach_session_exec(struct cmd *self, struct cmd_q *cmdq) +cmd_attach_session(struct cmd_q *cmdq, const char* tflag, int dflag, int rflag) { - struct args *args = self->args; struct session *s; struct client *c; const char *update; @@ -53,14 +52,14 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_q *cmdq) return (CMD_RETURN_ERROR); } - if ((s = cmd_find_session(cmdq, args_get(args, 't'), 1)) == NULL) + if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL) return (CMD_RETURN_ERROR); if (cmdq->client == NULL) return (CMD_RETURN_NORMAL); if (cmdq->client->session != NULL) { - if (args_has(self->args, 'd')) { + if (dflag) { /* * Can't use server_write_session in case attaching to * the same session as currently attached to. @@ -87,10 +86,10 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_q *cmdq) return (CMD_RETURN_ERROR); } - if (args_has(self->args, 'r')) + if (rflag) cmdq->client->flags |= CLIENT_READONLY; - if (args_has(self->args, 'd')) + if (dflag) server_write_session(s, MSG_DETACH, NULL, 0); update = options_get_string(&s->options, "update-environment"); @@ -110,3 +109,12 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_q *cmdq) return (CMD_RETURN_NORMAL); } + +enum cmd_retval +cmd_attach_session_exec(struct cmd *self, struct cmd_q *cmdq) +{ + struct args *args = self->args; + + return (cmd_attach_session(cmdq, args_get(args, 't'), + args_has(args, 'd'), args_has(args, 'r'))); +} |