try this, against CVS HEAD

Index: cmd-new-session.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/cmd-new-session.c,v
retrieving revision 1.34
diff -u -p -r1.34 cmd-new-session.c
--- cmd-new-session.c   4 Jan 2011 00:42:47 -0000       1.34
+++ cmd-new-session.c   12 Jan 2011 21:40:52 -0000
@@ -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 *, s
 
 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, s
        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, s
        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, "heigh %s", errstr);
+                               return (-1);
+                       }
+               }
        } else if (ctx->cmdclient != NULL) {
                sx = ctx->cmdclient->tty.sx;
                sy = ctx->cmdclient->tty.sy;


On Wed, Jan 12, 2011 at 09:32:00PM +0000, Nicholas Marriott wrote:
> someone else asked for a way to set the initial size but they didn't
> really give a convincing use case so i didn't do it
> 
> what you can do to get it the right size is do
> 
> tmux new\; detach
> 
> rather than new -d
> 
> you can resize the panes after you've created them
> 
> tmux new -d\; splitw -d\; resizep -U 100\; resizep -D 1\; attach
> 
> or alternatively
> 
> tmux new -d\; splitw -d\; set -g main-pane-height 2\; selectl 
> main-horizontal\; set -u main-pane-height\; attach
> 
> of course this doesn't really help unless you can make the window the
> right size
> 
> 
> 
> On Wed, Jan 12, 2011 at 07:02:50PM +0100, hubert depesz lubaczewski wrote:
> > On Wed, Jan 12, 2011 at 12:58:27PM -0500, Patrick Shanahan wrote:
> > > * hubert depesz lubaczewski <dep...@depesz.com> [01-12-11 11:53]:
> > > > 
> > > > that is - I use 3 panels, split horizontally, with the top 2 having 
> > > > predefined, fixed height of 10 lines.
> > > > 
> > > > Now - I know I can make it myself, but running tmux, doing the split, 
> > > > and then
> > > > manually changing sizes of panes, but I'm looking for a script-based 
> > > > way to do
> > > > it.
> > > > 
> > > > In general - I need a script that will:
> > > > 1. check for existing session
> > > > 2. if the session exists - exit
> > > > 3. if it doesn't exist - make new one, detached
> > > > 4. in the new session, on first window, make 3 panes, change their 
> > > > sizes to 10 lines, 10 lines, rest
> > > > 
> > > > i checked the docs and examples, and even bugged people on irc, but I 
> > > > wasn't able to get to a way to do it.
> > > 
> > > get an xterm window with size 136x52 at 575+20
> > >    black on white
> > >    title "Pakas Tmux ML"
> > >    attaches existing session or starts new if no existing
> > > 
> > > xterm -geometry 136x52+575+20 -ls -bg white -fg black \
> > >       -title "Pakas Tmux ML" -e tmux -2u attach 
> > > 
> > > 
> > > 
> > > ~/.tmux.conf
> > >   split-window -v -l 10
> > >   swap-pane -U
> > >   split-window -v -l 10
> > >   
> > > 
> > > will give you three panes but the two lowers will be 10 lines each
> > 
> > I know about split -l, but as you said - it will work for lower panes
> > only. any way to do it with top panes?
> > 
> > as for the xterm command - most of the steps I can do on my own, i have
> > problems only with the 10 lines requirement, and too small default
> > *detached* window.
> > 
> > Best regards,
> > 
> > depesz
> > 
> > 
> > ------------------------------------------------------------------------------
> > Protect Your Site and Customers from Malware Attacks
> > Learn about various malware tactics and how to avoid them. Understand 
> > malware threats, the impact they can have on your business, and how you 
> > can protect your company and customers by using code signing.
> > http://p.sf.net/sfu/oracle-sfdevnl
> > _______________________________________________
> > tmux-users mailing list
> > tmux-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/tmux-users

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to