New session selection rules:

- find by name if given
	- otherwise try current index from $TMUX
	- otherwise if only one session, use it
	- otherwise error
This commit is contained in:
Nicholas Marriott
2007-09-27 09:52:03 +00:00
parent 3fa8f16364
commit 22990a6595
7 changed files with 131 additions and 57 deletions

View File

@ -1,4 +1,4 @@
/* $Id: session.c,v 1.16 2007-09-27 09:15:58 nicm Exp $ */
/* $Id: session.c,v 1.17 2007-09-27 09:52:03 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -112,13 +112,13 @@ session_new(struct session *s, const char *cmd, u_int sx, u_int sy)
{
struct window *w;
const char *environ[] = { NULL, "TERM=screen", NULL };
char blk[256];
char buf[256];
u_int i;
if (session_index(s, &i) != 0)
fatalx("session not found");
xsnprintf(blk, sizeof blk, "TMUX=%ld,%u", (long) getpid(), i);
environ[0] = blk;
xsnprintf(buf, sizeof buf, "TMUX=%ld,%u", (long) getpid(), i);
environ[0] = buf;
if ((w = window_create(cmd, environ, sx, sy)) == NULL)
return (-1);