summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2011-01-14 23:49:24 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2011-01-14 23:49:24 +0000
commitf0276a021c053e42c0f8e1bda37ece86df791612 (patch)
tree7f23f1ae2e3fecff9d9af508c3730e38669a8a3b /usr.bin/tmux
parentcf7a0c3a995a8bf3b09da4cf8f62eb65d27a094a (diff)
Support -x and -y for new-session to specify the initial size of the
window if created detached with -d.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/cmd-new-session.c29
-rw-r--r--usr.bin/tmux/tmux.113
2 files changed, 36 insertions, 6 deletions
diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c
index ecb1c1acacd..2b16680842a 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.34 2011/01/04 00:42:47 nicm Exp $ */
+/* $OpenBSD: cmd-new-session.c,v 1.35 2011/01/14 23:49:23 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <pwd.h>
+#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
@@ -34,8 +35,9 @@ int cmd_new_session_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_new_session_entry = {
"new-session", "new",
- "dn:s:t:", 0, 1,
- "[-d] [-n window-name] [-s session-name] [-t target-session] [command]",
+ "dn:s:t:x:y:", 0, 1,
+ "[-d] [-n window-name] [-s session-name] [-t target-session] "
+ "[-x width] [-y height] [command]",
CMD_STARTSERVER|CMD_CANTNEST|CMD_SENDENVIRON,
NULL,
cmd_new_session_check,
@@ -47,6 +49,9 @@ cmd_new_session_check(struct args *args)
{
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n')))
return (-1);
+ if (!args_has(args, 'd') &&
+ (args_has(args, 'x') || args_has(args, 'y')))
+ return (-1);
return (0);
}
@@ -60,7 +65,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
struct environ env;
struct termios tio, *tiop;
struct passwd *pw;
- const char *newname, *target, *update, *cwd;
+ const char *newname, *target, *update, *cwd, *errstr;
char *overrides, *cmd, *cause;
int detached, idx;
u_int sx, sy, i;
@@ -149,6 +154,22 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
if (detached) {
sx = 80;
sy = 24;
+ if (args_has(args, 'x')) {
+ sx = strtonum(
+ args_get(args, 'x'), 1, USHRT_MAX, &errstr);
+ if (errstr != NULL) {
+ ctx->error(ctx, "width %s", errstr);
+ return (-1);
+ }
+ }
+ if (args_has(args, 'y')) {
+ sy = strtonum(
+ args_get(args, 'y'), 1, USHRT_MAX, &errstr);
+ if (errstr != NULL) {
+ ctx->error(ctx, "height %s", errstr);
+ return (-1);
+ }
+ }
} else if (ctx->cmdclient != NULL) {
sx = ctx->cmdclient->tty.sx;
sy = ctx->cmdclient->tty.sy;
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index ee4fada9992..05fcee6c72f 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.209 2011/01/13 09:50:11 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.210 2011/01/14 23:49:23 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -14,7 +14,7 @@
.\" 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: January 13 2011 $
+.Dd $Mdocdate: January 14 2011 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -591,6 +591,8 @@ Lock all clients attached to
.Op Fl n Ar window-name
.Op Fl s Ar session-name
.Op Fl t Ar target-session
+.Op Fl x Ar width
+.Op Fl y Ar height
.Op Ar shell-command
.Xc
.D1 (alias: Ic new )
@@ -604,6 +606,13 @@ is given.
and
.Ar shell-command
are the name of and shell command to execute in the initial window.
+If
+.Fl d
+is used,
+.Fl x
+and
+.Fl y
+specify the size of the initial window (80 by 24 if not given).
.Pp
If run from a terminal, any
.Xr termios 4