aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2007-09-26 14:08:16 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2007-09-26 14:08:16 +0000
commit65eeb7e421718e248790d858792fd820aabbdbe6 (patch)
treea145930e554bfb8a0609d588a8a95f740622f8de
parentfb39b22a2e7b7c12c56b26abc8ca18f38c2d7bda (diff)
downloadrtmux-65eeb7e421718e248790d858792fd820aabbdbe6.tar.gz
rtmux-65eeb7e421718e248790d858792fd820aabbdbe6.tar.bz2
rtmux-65eeb7e421718e248790d858792fd820aabbdbe6.zip
Restore -n, now after the command.
-rw-r--r--NOTES9
-rw-r--r--op.c51
-rw-r--r--tmux.c9
3 files changed, 51 insertions, 18 deletions
diff --git a/NOTES b/NOTES
index bcc1b0ee..eacc1308 100644
--- a/NOTES
+++ b/NOTES
@@ -12,7 +12,6 @@ Commands: d detach
p previous window
l last (next to last selected) window
r refresh screen
- t set window name
w list current windows
0-9 select window
@@ -21,7 +20,7 @@ There is one default server process per user which puts its socket in
invocations will connect to the same server. The server holds multiple
sessions.
-Syntax is: tmux [-v] [-n name] [-s path] command
+Syntax is: tmux [-v] [-s path] command [flags]
The command is either list, new or attach. Create a new session with:
@@ -29,11 +28,11 @@ The command is either list, new or attach. Create a new session with:
Optionally giving it a name with:
- tmux -n <session name> new
+ tmux new -n <session name>
Attach to a previous session with:
- tmux -n <session name> attach
+ tmux attach -n <session name>
A name must (currently) be specified when attaching. This may change.
@@ -43,7 +42,7 @@ List all sessions with:
Or the windows of a single session with:
- tmux -n <session name> list
+ tmux list -n <session name>
Sessions are destroyed when no windows remain attached to them.
diff --git a/op.c b/op.c
index 393ca69f..f5fa1485 100644
--- a/op.c
+++ b/op.c
@@ -1,4 +1,4 @@
-/* $Id: op.c,v 1.1 2007-09-26 13:43:15 nicm Exp $ */
+/* $Id: op.c,v 1.2 2007-09-26 14:08:16 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <string.h>
+#include <unistd.h>
#include "tmux.h"
@@ -27,14 +28,32 @@ op_new(char *path, int argc, unused char **argv)
{
struct new_data data;
struct client_ctx cctx;
+ char name[MAXNAMELEN];
+ int opt;
- if (argc != 0) /* XXX -n */
- return (usage("new"));
+ optind = 1;
+ while ((opt = getopt(argc, argv, "n:?")) != EOF) {
+ switch (opt) {
+ case 'n':
+ if (strlcpy(name, optarg, sizeof name) >= sizeof name) {
+ log_warnx("%s: session name too long", optarg);
+ return (1);
+ }
+ break;
+ case '?':
+ default:
+ return (usage("new [-n session]"));
+ }
+ }
+ argc -= optind;
+ argv += optind;
+ if (argc != 0)
+ return (usage("new [-n session]"));
if (client_init(path, &cctx, 1) != 0)
return (1);
- strlcpy(data.name, "XXX"/*XXX*/, sizeof data.name);
+ strlcpy(data.name, name, sizeof data.name);
data.sx = cctx.ws.ws_col;
data.sy = cctx.ws.ws_row;
client_write_server(&cctx, MSG_NEW, &data, sizeof data);
@@ -47,14 +66,32 @@ op_attach(char *path, int argc, unused char **argv)
{
struct attach_data data;
struct client_ctx cctx;
+ char name[MAXNAMELEN];
+ int opt;
- if (argc != 0) /* XXX -n */
- return (usage("attach"));
+ optind = 1;
+ while ((opt = getopt(argc, argv, "n:?")) != EOF) {
+ switch (opt) {
+ case 'n':
+ if (strlcpy(name, optarg, sizeof name) >= sizeof name) {
+ log_warnx("%s: session name too long", optarg);
+ return (1);
+ }
+ break;
+ case '?':
+ default:
+ return (usage("attach [-n session]"));
+ }
+ }
+ argc -= optind;
+ argv += optind;
+ if (argc != 0)
+ return (usage("attach [-n session]"));
if (client_init(path, &cctx, 1) != 0)
return (1);
- strlcpy(data.name, "XXX"/*XXX*/, sizeof data.name);
+ strlcpy(data.name, name, sizeof data.name);
data.sx = cctx.ws.ws_col;
data.sy = cctx.ws.ws_row;
client_write_server(&cctx, MSG_ATTACH, &data, sizeof data);
diff --git a/tmux.c b/tmux.c
index 6ae982eb..bc5718fd 100644
--- a/tmux.c
+++ b/tmux.c
@@ -1,4 +1,4 @@
-/* $Id: tmux.c,v 1.9 2007-09-26 13:43:15 nicm Exp $ */
+/* $Id: tmux.c,v 1.10 2007-09-26 14:08:16 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -53,7 +53,7 @@ int
usage(const char *s)
{
if (s == NULL)
- s = "command ...";
+ s = "command [flags]";
fprintf(stderr, "usage: %s [-v] [-s path] %s\n", __progname, s);
return (1);
}
@@ -182,11 +182,8 @@ main(int argc, char **argv)
for (i = 0; i < NOP; i++) {
op = op_table + i;
- if (strncmp(argv[0], op->cmd, strlen(op->cmd)) == 0) {
- argc--;
- argv++;
+ if (strncmp(argv[0], op->cmd, strlen(op->cmd)) == 0)
exit(op->fn(path, argc, argv));
- }
}
exit(usage(NULL));