Last bits of basic configuration file. By default in ~/.tmux.conf or specified with -f. Just a list of tmux commands executed when the server is started and before and any session/window is created.

pull/1/head
Nicholas Marriott 2008-06-02 21:08:36 +00:00
parent f6b86402c7
commit a26f58c7c3
27 changed files with 175 additions and 129 deletions

40
CHANGES
View File

@ -1,5 +1,43 @@
02 June 2008
* New command, start-server (alias "start"), to start the tmux server and do
nothing else. This is good if you have a configuration file which creates
windows or sessions (like me): in that case, starting the server the first
time tmux new is run is bad since it creates a new session and window (as
it is supposed to - starting the server is a side-effect).
Instead, I have a little script which does the equivalent of:
tmux has -s0 2>/dev/null || tmux start
tmux attach -d -s0
And I use it to start the server if necessary and attach to my primary
session.
* Basic configuration file in ~/.tmux.conf or specified with -f. This is file
contains a set of tmux commands that are run the first time the server is
started. The configuration commands are executed before any others, so
if you have a configuration file that contains:
new -d
neww -s0
And you do the following without an existing server running:
tmux new
You will end up with two sessions, session 0 with two windows (created by
the configuration file) and your client attached to session 1 with one
window (created by the command-line command). I'm not completely happy with
this, it seems a little non-obvious, but I haven't yet decided what to do
about it.
There is no environment variable handling or other special stuff yet.
In the future, it might be nice to be able to have per-session configuration
settings, probably by having conditionals in the file (so you could, for
example, have commands to define a particular window layout that would only
be invoked if you called tmux new -smysession and mysession did not already
exist).
* BIG CHANGE: -s and -c to specify session name and client name are now passed
after the command rather than before it. So, for example:
@ -330,4 +368,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
$Id: CHANGES,v 1.97 2008-06-02 18:08:16 nicm Exp $
$Id: CHANGES,v 1.98 2008-06-02 21:08:36 nicm Exp $

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.54 2008-06-02 18:08:16 nicm Exp $
# $Id: Makefile,v 1.55 2008-06-02 21:08:36 nicm Exp $
.SUFFIXES: .c .o .y .h
.PHONY: clean update-index.html upload-index.html
@ -27,8 +27,9 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
cmd-link-window.c cmd-unlink-window.c cmd-next-window.c cmd-send-keys.c \
cmd-swap-window.c cmd-rename-session.c cmd-kill-session.c \
cmd-switch-client.c cmd-has-session.c cmd-scroll-mode.c cmd-copy-mode.c \
cmd-paste-buffer.c cmd-new-session.c window-scroll.c window-more.c \
window-copy.c tty.c tty-keys.c tty-write.c screen-write.c screen-redraw.c
cmd-paste-buffer.c cmd-new-session.c cmd-start-server.c \
window-scroll.c window-more.c window-copy.c \
tty.c tty-keys.c tty-write.c screen-write.c screen-redraw.c
CC?= cc
INCDIRS+= -I. -I- -I/usr/local/include

1
TODO
View File

@ -69,6 +69,7 @@
- tobiasu says it is borken on Linux with aterm + TERM=rxvt
- poll(2) is broken on OS X/Darwin, a workaround for this would be nice
- different screen model? layers perhaps? hmm
- cfg file improvements: * comments to EOL
---
[18:20] *priteau* i found something in tmux that could be tweaked to be better

25
cfg.c
View File

@ -1,4 +1,4 @@
/* $Id: cfg.c,v 1.3 2008-06-02 18:55:53 nicm Exp $ */
/* $Id: cfg.c,v 1.4 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -73,7 +73,7 @@ load_cfg(const char *path, char **causep)
buf = NULL;
len = 0;
line = 1;
line = 0;
while ((ch = getc(f)) != EOF) {
switch (ch) {
case '#':
@ -98,17 +98,18 @@ load_cfg(const char *path, char **causep)
case EOF:
case ' ':
case '\t':
if (len == 0)
break;
buf[len] = '\0';
if (len != 0) {
buf[len] = '\0';
argv = xrealloc(argv, argc + 1, sizeof (char *));
argv[argc++] = buf;
buf = NULL;
len = 0;
argv = xrealloc(
argv, argc + 1, sizeof (char *));
argv[argc++] = buf;
buf = NULL;
len = 0;
}
if (ch != '\n' && ch != EOF)
if ((ch != '\n' && ch != EOF) || argc == 0)
break;
line++;
@ -123,7 +124,7 @@ load_cfg(const char *path, char **causep)
ctx.print = cfg_print;
ctx.cmdclient = NULL;
ctx.flags = CMD_KEY;
ctx.flags = 0;
cfg_cause = NULL;
cmd_exec(cmd, &ctx);

View File

@ -1,4 +1,4 @@
/* $Id: client.c,v 1.27 2008-06-01 21:24:33 nicm Exp $ */
/* $Id: client.c,v 1.28 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -45,13 +45,15 @@ client_init(const char *path, struct client_ctx *cctx, int start_server)
int mode;
u_int retries;
struct buffer *b;
pid_t pid;
pid = 0;
retries = 0;
retry:
if (stat(path, &sb) != 0) {
if (start_server && errno == ENOENT && retries < 10) {
if (server_start(path) != 0)
return (-1);
if (pid == 0)
pid = server_start(path);
usleep(10000);
retries++;
goto retry;
@ -112,7 +114,7 @@ retry:
fail:
log_warn("server not found");
return (-1);
return (1);
}
int

View File

@ -1,4 +1,4 @@
/* $Id: cmd-attach-session.c,v 1.12 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-attach-session.c,v 1.13 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -79,7 +79,7 @@ cmd_attach_session_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
cmd_attach_session_free(data);
return (-1);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-bind-key.c,v 1.9 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-bind-key.c,v 1.10 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -82,7 +82,7 @@ cmd_bind_key_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
error:
cmd_bind_key_free(data);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-generic.c,v 1.1 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-generic.c,v 1.2 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -57,7 +57,7 @@ cmd_clientonly_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
self->entry->free(data);
return (-1);
@ -129,7 +129,7 @@ cmd_sessiononly_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
self->entry->free(data);
return (-1);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-has-session.c,v 1.4 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-has-session.c,v 1.5 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -24,27 +24,30 @@
#include "tmux.h"
/*
* Cause client to exit with 0 if session exists, or 1 if it doesn't. This
* is handled in the caller since this doesn't have flag CMD_NOSESSION, so
* all that is necessary is to exit.
* Cause client to report an error and exit with 1 if session doesn't exist.
*/
void cmd_has_session_exec(void *, struct cmd_ctx *);
const struct cmd_entry cmd_has_session_entry = {
"has-session", "has",
"",
CMD_SESSIONONLY_USAGE,
0,
NULL,
cmd_sessiononly_parse,
cmd_has_session_exec,
NULL,
NULL,
NULL
cmd_sessiononly_send,
cmd_sessiononly_recv,
cmd_sessiononly_free
};
void
cmd_has_session_exec(unused void *ptr, struct cmd_ctx *ctx)
cmd_has_session_exec(void *ptr, struct cmd_ctx *ctx)
{
struct session *s;
if ((s = cmd_sessiononly_get(ptr, ctx)) == NULL)
return;
if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}

View File

@ -1,4 +1,4 @@
/* $Id: cmd-kill-window.c,v 1.8 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-kill-window.c,v 1.9 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -85,7 +85,7 @@ cmd_kill_window_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
error:
cmd_kill_window_free(data);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-link-window.c,v 1.11 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-link-window.c,v 1.12 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -106,7 +106,7 @@ cmd_link_window_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
error:
cmd_link_window_free(data);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-new-session.c,v 1.20 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-new-session.c,v 1.21 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -89,7 +89,7 @@ cmd_new_session_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
cmd_new_session_free(data);
return (-1);
@ -101,8 +101,9 @@ cmd_new_session_exec(void *ptr, struct cmd_ctx *ctx)
struct cmd_new_session_data *data = ptr;
struct cmd_new_session_data std = { NULL, NULL, NULL, 0 };
struct client *c = ctx->cmdclient;
struct session *s;
char *cmd, *cause;
u_int sy;
u_int sx, sy;
if (data == NULL)
data = &std;
@ -110,9 +111,15 @@ cmd_new_session_exec(void *ptr, struct cmd_ctx *ctx)
if (ctx->flags & CMD_KEY)
return;
if (!data->flag_detached && !(c->flags & CLIENT_TERMINAL)) {
ctx->error(ctx, "not a terminal");
return;
if (!data->flag_detached) {
if (c == NULL) {
ctx->error(ctx, "no client to attach to");
return;
}
if (!(c->flags & CLIENT_TERMINAL)) {
ctx->error(ctx, "not a terminal");
return;
}
}
if (data->name != NULL && session_find(data->name) != NULL) {
@ -120,7 +127,16 @@ cmd_new_session_exec(void *ptr, struct cmd_ctx *ctx)
return;
}
sy = c->sy;
cmd = data->cmd;
if (cmd == NULL)
cmd = default_command;
sx = 80;
sy = 25;
if (!data->flag_detached) {
sx = c->sx;
sy = c->sy;
}
if (sy < status_lines)
sy = status_lines + 1;
sy -= status_lines;
@ -131,21 +147,19 @@ cmd_new_session_exec(void *ptr, struct cmd_ctx *ctx)
return;
}
cmd = data->cmd;
if (cmd == NULL)
cmd = default_command;
c->session = session_create(data->name, cmd, c->sx, sy);
if (c->session == NULL)
if ((s = session_create(data->name, cmd, sx, sy)) == NULL)
fatalx("session_create failed");
if (data->winname != NULL) {
xfree(c->session->curw->window->name);
c->session->curw->window->name = xstrdup(data->winname);
xfree(s->curw->window->name);
s->curw->window->name = xstrdup(data->winname);
}
if (data->flag_detached)
server_write_client(c, MSG_EXIT, NULL, 0);
else {
if (data->flag_detached) {
if (c != NULL)
server_write_client(c, MSG_EXIT, NULL, 0);
} else {
c->session = s;
server_write_client(c, MSG_READY, NULL, 0);
server_redraw_client(c);
}

View File

@ -1,4 +1,4 @@
/* $Id: cmd-new-window.c,v 1.15 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-new-window.c,v 1.16 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -100,7 +100,7 @@ cmd_new_window_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
error:
cmd_new_window_free(data);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-rename-session.c,v 1.5 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-rename-session.c,v 1.6 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -79,7 +79,7 @@ cmd_rename_session_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
cmd_rename_session_free(data);
return (-1);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-rename-window.c,v 1.15 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-rename-window.c,v 1.16 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -89,7 +89,7 @@ cmd_rename_window_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
error:
cmd_rename_window_free(data);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-select-window.c,v 1.12 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-select-window.c,v 1.13 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -98,7 +98,7 @@ cmd_select_window_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
error:
cmd_select_window_free(data);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-send-keys.c,v 1.2 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-send-keys.c,v 1.3 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -95,7 +95,7 @@ cmd_send_keys_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
cmd_send_keys_free(data);
return (-1);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-set-option.c,v 1.16 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-set-option.c,v 1.17 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -79,7 +79,7 @@ cmd_set_option_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
cmd_set_option_free(data);
return (-1);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-swap-window.c,v 1.5 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-swap-window.c,v 1.6 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -101,7 +101,7 @@ cmd_swap_window_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
error:
cmd_swap_window_free(data);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-switch-client.c,v 1.3 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-switch-client.c,v 1.4 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -80,7 +80,7 @@ cmd_switch_client_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
cmd_switch_client_free(data);
return (-1);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-unbind-key.c,v 1.9 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-unbind-key.c,v 1.10 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -75,7 +75,7 @@ cmd_unbind_key_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
error:
xfree(data);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-unlink-window.c,v 1.6 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd-unlink-window.c,v 1.7 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -85,7 +85,7 @@ cmd_unlink_window_parse(
return (0);
usage:
usage(cause, "%s %s", self->entry->name, self->entry->usage);
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
error:
cmd_unlink_window_free(data);

5
cmd.c
View File

@ -1,4 +1,4 @@
/* $Id: cmd.c,v 1.35 2008-06-02 18:08:16 nicm Exp $ */
/* $Id: cmd.c,v 1.36 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -51,6 +51,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_send_keys_entry,
&cmd_send_prefix_entry,
&cmd_set_option_entry,
&cmd_start_server_entry,
&cmd_swap_window_entry,
&cmd_switch_client_entry,
&cmd_unbind_key_entry,
@ -128,7 +129,7 @@ ambiguous:
return (NULL);
usage:
usage(cause, "%s %s", entry->name, entry->usage);
xasprintf(cause, "usage: %s %s", entry->name, entry->usage);
return (NULL);
}

View File

@ -1,4 +1,4 @@
/* $Id: server.c,v 1.46 2008-06-02 18:08:17 nicm Exp $ */
/* $Id: server.c,v 1.47 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -55,28 +55,39 @@ void server_lost_client(struct client *);
void server_lost_window(struct window *);
/* Fork new server. */
int
pid_t
server_start(const char *path)
{
struct sockaddr_un sa;
size_t size;
mode_t mask;
int n, fd, mode;
pid_t pid;
char *cause;
switch (fork()) {
switch (pid = fork()) {
case -1:
fatal("fork");
case 0:
break;
default:
return (0);
return (pid);
}
#ifdef DEBUG
xmalloc_clear();
#endif
ARRAY_INIT(&windows);
ARRAY_INIT(&clients);
ARRAY_INIT(&sessions);
key_bindings_init();
if (cfg_file != NULL && load_cfg(cfg_file, &cause) != 0) {
log_warnx("%s", cause);
exit(1);
}
logfile("server");
#ifndef NO_SETPROCTITLE
setproctitle("server (%s)", path);
@ -110,17 +121,10 @@ server_start(const char *path)
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
fatal("fcntl failed");
/* Load configuration. */
if (cfg_file != NULL && load_cfg(cfg_file, &cause) != 0) {
log_warnx("%s", cause);
xfree(cause);
exit(1);
}
if (daemon(1, 1) != 0)
fatal("daemon failed");
log_debug("server daemonised, pid now %ld", (long) getpid());
n = server_main(path, fd);
#ifdef DEBUG
xmalloc_report(getpid(), "server");
@ -137,12 +141,6 @@ server_main(const char *srv_path, int srv_fd)
u_int i;
siginit();
ARRAY_INIT(&windows);
ARRAY_INIT(&clients);
ARRAY_INIT(&sessions);
key_bindings_init();
pfds = NULL;
while (!sigterm) {

View File

@ -1,4 +1,4 @@
/* $Id: session.c,v 1.30 2007-12-06 09:46:23 nicm Exp $ */
/* $Id: session.c,v 1.31 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -117,6 +117,8 @@ session_create(const char *name, const char *cmd, u_int sx, u_int sy)
}
session_select(s, 0);
log_debug("session %s created", s->name);
return (s);
}
@ -126,6 +128,8 @@ session_destroy(struct session *s)
{
u_int i;
log_debug("session %s destroyed", s->name);
if (session_index(s, &i) != 0)
fatalx("session not found");
ARRAY_SET(&sessions, i, NULL);

37
tmux.c
View File

@ -1,4 +1,4 @@
/* $Id: tmux.c,v 1.47 2008-06-02 18:08:17 nicm Exp $ */
/* $Id: tmux.c,v 1.48 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -53,25 +53,15 @@ u_int history_limit;
u_int status_lines;
void sighandler(int);
__dead void usage(void);
void
usage(char **ptr, const char *fmt, ...)
__dead void
usage(void)
{
char *msg;
va_list ap;
#define USAGE "usage: %s [-v] [-f file] [-S socket-path]"
if (fmt == NULL) {
xasprintf(ptr, USAGE " command [flags]", __progname);
} else {
va_start(ap, fmt);
xvasprintf(&msg, fmt, ap);
va_end(ap);
xasprintf(ptr, USAGE " %s", __progname, msg);
xfree(msg);
}
#undef USAGE
fprintf(stderr,
"usage: %s [-v] [-f file] [-S socket-path] command [flags]",
__progname);
exit(1);
}
void
@ -202,13 +192,13 @@ main(int argc, char **argv)
printf("%s " BUILD "\n", __progname);
exit(0);
default:
goto usage;
usage();
}
}
argc -= optind;
argv += optind;
if (argc == 0)
goto usage;
usage();
log_open(stderr, LOG_USER, debug_level);
siginit();
@ -275,8 +265,6 @@ main(int argc, char **argv)
xasprintf(&default_command, "exec %s", shell);
if ((cmd = cmd_parse(argc, argv, &cause)) == NULL) {
if (cause == NULL)
goto usage;
log_warnx("%s", cause);
exit(1);
}
@ -354,9 +342,4 @@ out:
xmalloc_report(getpid(), "client");
#endif
return (n);
usage:
usage(&cause, NULL);
fprintf(stderr, "%s\n", cause);
exit(1);
}

6
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.117 2008-06-02 18:08:17 nicm Exp $ */
/* $Id: tmux.h,v 1.118 2008-06-02 21:08:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -693,7 +693,6 @@ extern int prefix_key;
extern u_char status_colour;
extern u_int history_limit;
extern u_int status_lines;
void usage(char **, const char *, ...);
void logfile(const char *);
void siginit(void);
void sigreset(void);
@ -759,6 +758,7 @@ extern const struct cmd_entry cmd_select_window_entry;
extern const struct cmd_entry cmd_send_keys_entry;
extern const struct cmd_entry cmd_send_prefix_entry;
extern const struct cmd_entry cmd_set_option_entry;
extern const struct cmd_entry cmd_start_server_entry;
extern const struct cmd_entry cmd_swap_window_entry;
extern const struct cmd_entry cmd_switch_client_entry;
extern const struct cmd_entry cmd_unbind_key_entry;
@ -809,7 +809,7 @@ const char *key_string_lookup_key(int);
/* server.c */
extern struct clients clients;
int server_start(const char *);
pid_t server_start(const char *);
/* server-msg.c */
int server_msg_dispatch(struct client *);