1
0
mirror of https://github.com/tmux/tmux.git synced 2025-04-10 11:08:49 +00:00

Quick man page update, also fix some usages and get rid of some CMD_KEY checks.

This commit is contained in:
Nicholas Marriott 2008-06-02 21:36:51 +00:00
parent 259dcbbc93
commit 95cc21c251
11 changed files with 73 additions and 55 deletions

3
TODO
View File

@ -13,7 +13,6 @@
- decide about customised status line - decide about customised status line
- could use bsearch all over the place or get rid of smaller tables (clientmsg) - could use bsearch all over the place or get rid of smaller tables (clientmsg)
- better errors when creating new windows/sessions (how?) - better errors when creating new windows/sessions (how?)
- commands should have to care less about CMD_KEY
- session with CMD_NOSESSION should be an error - session with CMD_NOSESSION should be an error
- each command should have a print op as well for list keys - each command should have a print op as well for list keys
- Implicitly add exec to the commands for new windows (switch to disable it) - Implicitly add exec to the commands for new windows (switch to disable it)
@ -70,6 +69,8 @@
- poll(2) is broken on OS X/Darwin, a workaround for this would be nice - poll(2) is broken on OS X/Darwin, a workaround for this would be nice
- different screen model? layers perhaps? hmm - different screen model? layers perhaps? hmm
- cfg file improvements: * comments to EOL - cfg file improvements: * comments to EOL
- index on *-mode and other stuff that targets a window but is currently
sessiononly
--- ---
[18:20] *priteau* i found something in tmux that could be tweaked to be better [18:20] *priteau* i found something in tmux that could be tweaked to be better

4
cfg.c
View File

@ -1,4 +1,4 @@
/* $Id: cfg.c,v 1.4 2008-06-02 21:08:36 nicm Exp $ */ /* $Id: cfg.c,v 1.5 2008-06-02 21:36:51 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -153,7 +153,7 @@ load_cfg(const char *path, char **causep)
return (0); return (0);
error: error:
while (--argc > 0) while (--argc >= 0)
xfree(argv[argc]); xfree(argv[argc]);
xfree(argv); xfree(argv);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-copy-mode.c,v 1.5 2008-06-02 18:08:16 nicm Exp $ */ /* $Id: cmd-copy-mode.c,v 1.6 2008-06-02 21:36:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -48,7 +48,6 @@ cmd_copy_mode_exec(unused void *ptr, struct cmd_ctx *ctx)
if ((s = cmd_sessiononly_get(ptr, ctx)) == NULL) if ((s = cmd_sessiononly_get(ptr, ctx)) == NULL)
return; return;
if (ctx->flags & CMD_KEY)
window_set_mode(s->curw->window, &window_copy_mode); window_set_mode(s->curw->window, &window_copy_mode);
if (ctx->cmdclient != NULL) if (ctx->cmdclient != NULL)

View File

@ -1,4 +1,4 @@
/* $Id: cmd-link-window.c,v 1.12 2008-06-02 21:08:36 nicm Exp $ */ /* $Id: cmd-link-window.c,v 1.13 2008-06-02 21:36:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -44,7 +44,7 @@ struct cmd_link_window_data {
const struct cmd_entry cmd_link_window_entry = { const struct cmd_entry cmd_link_window_entry = {
"link-window", "linkw", "link-window", "linkw",
"[-dk] [-s session-name] [-i index] session-name index", "[-dk] [-i index] [-s session-name] session-name index",
0, 0,
cmd_link_window_parse, cmd_link_window_parse,
cmd_link_window_exec, cmd_link_window_exec,

View File

@ -1,4 +1,4 @@
/* $Id: cmd-new-session.c,v 1.21 2008-06-02 21:08:36 nicm Exp $ */ /* $Id: cmd-new-session.c,v 1.22 2008-06-02 21:36:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -41,7 +41,7 @@ struct cmd_new_session_data {
const struct cmd_entry cmd_new_session_entry = { const struct cmd_entry cmd_new_session_entry = {
"new-session", "new", "new-session", "new",
"[-d] [-s session-name] [-n window-name] [command]", "[-d] [-n window-name] [-s session-name] [command]",
CMD_STARTSERVER|CMD_CANTNEST, CMD_STARTSERVER|CMD_CANTNEST,
cmd_new_session_parse, cmd_new_session_parse,
cmd_new_session_exec, cmd_new_session_exec,

View File

@ -1,4 +1,4 @@
/* $Id: cmd-new-window.c,v 1.16 2008-06-02 21:08:36 nicm Exp $ */ /* $Id: cmd-new-window.c,v 1.17 2008-06-02 21:36:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -43,7 +43,7 @@ struct cmd_new_window_data {
const struct cmd_entry cmd_new_window_entry = { const struct cmd_entry cmd_new_window_entry = {
"new-window", "neww", "new-window", "neww",
"[-d] [-s session-name] [-i index] [-n name] [command]", "[-d] [-i index] [-n name] [-s session-name] [command]",
0, 0,
cmd_new_window_parse, cmd_new_window_parse,
cmd_new_window_exec, cmd_new_window_exec,

View File

@ -1,4 +1,4 @@
/* $Id: cmd-paste-buffer.c,v 1.3 2008-06-02 18:08:16 nicm Exp $ */ /* $Id: cmd-paste-buffer.c,v 1.4 2008-06-02 21:36:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -51,10 +51,8 @@ cmd_paste_buffer_exec(unused void *ptr, struct cmd_ctx *ctx)
return; return;
w = s->curw->window; w = s->curw->window;
if (ctx->flags & CMD_KEY && if (paste_buffer != NULL && *paste_buffer != '\0')
paste_buffer != NULL && *paste_buffer != '\0') {
buffer_write(w->out, paste_buffer, strlen(paste_buffer)); buffer_write(w->out, paste_buffer, strlen(paste_buffer));
}
if (ctx->cmdclient != NULL) if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-scroll-mode.c,v 1.7 2008-06-02 18:08:16 nicm Exp $ */ /* $Id: cmd-scroll-mode.c,v 1.8 2008-06-02 21:36:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -48,7 +48,6 @@ cmd_scroll_mode_exec(void *ptr, struct cmd_ctx *ctx)
if ((s = cmd_sessiononly_get(ptr, ctx)) == NULL) if ((s = cmd_sessiononly_get(ptr, ctx)) == NULL)
return; return;
if (ctx->flags & CMD_KEY)
window_set_mode(s->curw->window, &window_scroll_mode); window_set_mode(s->curw->window, &window_scroll_mode);
if (ctx->cmdclient != NULL) if (ctx->cmdclient != NULL)

View File

@ -1,4 +1,4 @@
/* $Id: cmd-send-keys.c,v 1.3 2008-06-02 21:08:36 nicm Exp $ */ /* $Id: cmd-send-keys.c,v 1.4 2008-06-02 21:36:51 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -40,7 +40,7 @@ struct cmd_send_keys_data {
}; };
const struct cmd_entry cmd_send_keys_entry = { const struct cmd_entry cmd_send_keys_entry = {
"send-keys", "send", "[-c client-name] key ...", "send-keys", "send", "[-c client-tty] key ...",
0, 0,
cmd_send_keys_parse, cmd_send_keys_parse,
cmd_send_keys_exec, cmd_send_keys_exec,

83
tmux.1
View File

@ -1,4 +1,4 @@
.\" $Id: tmux.1,v 1.24 2008-06-01 20:20:25 nicm Exp $ .\" $Id: tmux.1,v 1.25 2008-06-02 21:36:51 nicm Exp $
.\" .\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\" .\"
@ -24,9 +24,7 @@
.Nm tmux .Nm tmux
.Bk -words .Bk -words
.Op Fl vV .Op Fl vV
.Op Fl c Ar client-tty
.Op Fl S Ar socket-path .Op Fl S Ar socket-path
.Op Fl s Ar session-name
.Ar command .Ar command
.Op Ar arguments .Op Ar arguments
.Ek .Ek
@ -51,12 +49,6 @@ Communication takes place through a socket, by default placed in
.Pp .Pp
The options are as follows: The options are as follows:
.Bl -tag -width "XXXXXXXXXXXX" .Bl -tag -width "XXXXXXXXXXXX"
.It Fl c Ar client-tty
Apply command to the client on the given tty.
Clients may be listed with the
.Ic list-clients
command (see below).
This option does not apply to all commands.
.It Fl S Ar socket-path .It Fl S Ar socket-path
Specify an alternative path to the server socket. Specify an alternative path to the server socket.
The default is The default is
@ -65,17 +57,6 @@ where
.Em UID .Em UID
is the uid of the user who invoked is the uid of the user who invoked
.Nm . .Nm .
.It Fl s Ar session-name
Apply command to the session named
.Ar session-name .
This option does not apply to all commands.
If it is omitted and
.Nm
is invoked from a running
.Nm
client, the session the containing client is connected to will be used;
otherwise, if only one session exists, it is chosen, or if multiple sessions
exist, an error is generated.
.It Fl v .It Fl v
Request verbose logging. Request verbose logging.
This option may be specified multiple times for increasing verbosity. This option may be specified multiple times for increasing verbosity.
@ -241,11 +222,32 @@ command, bound to
by default. by default.
.El .El
.Sh COMMANDS .Sh COMMANDS
This section contains a list of the commands supported by
.Nm .
There are some flags shared by several commands; these are:
.Bl -tag -width "XXXXXXXXXXXX"
.It Fl c Ar client-tty
Apply command to the client on the given tty.
Clients may be listed with the
.Ic list-clients
command.
.It Fl s Ar session-name
Apply command to the session named
.Ar session-name .
If it is omitted and
.Nm .Nm
supports the following commands: is invoked from a running
.Nm
client, the session the containing client is connected to will be used;
otherwise, if only one session exists, it is chosen, or if multiple sessions
exist, an error is generated.
.El
.Pp
The following commands are available:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Xo Ic attach-session .It Xo Ic attach-session
.Op Fl d .Op Fl d
.Op Fl s Ar session-name
.Xc .Xc
.D1 (alias: Ic attach ) .D1 (alias: Ic attach )
Create a new client in the current terminal and attach it to a session. Create a new client in the current terminal and attach it to a session.
@ -261,37 +263,43 @@ Bind key
to to
.Ar command . .Ar command .
.It Xo Ic copy-mode .It Xo Ic copy-mode
.Op Fl s Ar session-name
.Xc .Xc
Enter copy mode. Enter copy mode.
This command does nothing unless bound to a key.
.It Xo Ic detach-client .It Xo Ic detach-client
.Op Fl c Ar client-tty
.Xc .Xc
.D1 (alias: Ic detach ) .D1 (alias: Ic detach )
Detach the current client if bound to a key, or the specified client with Detach the current client if bound to a key, or the specified client with
.Fl c . .Fl c .
.It Xo Ic has-session .It Xo Ic has-session
.Op Fl s Ar session-name
.Xc .Xc
.D1 (alias: Ic has ) .D1 (alias: Ic has )
Report an error and exit with 1 if the specified session does not exist. If it Report an error and exit with 1 if the specified session does not exist. If it
does exist, exit with 0. does exist, exit with 0.
.It Xo Ic kill-session .It Xo Ic kill-session
.Op Fl s Ar session-name
.Xc .Xc
Destroy the given session, closing any windows linked to it and no other Destroy the given session, closing any windows linked to it and no other
sessions, and detaching all clients attached to it. sessions, and detaching all clients attached to it.
.It Xo Ic kill-window .It Xo Ic kill-window
.Op Fl i Ar index .Op Fl i Ar index
.Op Fl s Ar session-name
.Xc .Xc
.D1 (alias: Ic killw ) .D1 (alias: Ic killw )
Kill the current window or the window at Kill the current window or the window at
.Ar index , .Ar index ,
removing it from any sessions to which it is linked. removing it from any sessions to which it is linked.
.It Xo Ic last-window .It Xo Ic last-window
.Op Fl s Ar session-name
.Xc .Xc
.D1 (alias: Ic last ) .D1 (alias: Ic last )
Select the last (previously selected) window. Select the last (previously selected) window.
.It Xo Ic link-window .It Xo Ic link-window
.Op Fl dk .Op Fl dk
.Op Fl i Ar destination-index .Op Fl i Ar index
.Op Fl s Ar session-name
.Ar source-name Ar source-index .Ar source-name Ar source-index
.Xc .Xc
.D1 (alias: Ic linkw ) .D1 (alias: Ic linkw )
@ -300,13 +308,13 @@ Link the window at
in session in session
.Ar source-name .Ar source-name
into the specified session. If into the specified session. If
.Ar destination-index .Ar index
is specified and no window exists with that index, the window is linked at is specified and no window exists with that index, the window is linked at
that index. that index.
If If
.Fl k .Fl k
is given and a window exists at is given and a window exists at
.Ar destination-index , .Ar index ,
it is killed, otherwise an error is generated. it is killed, otherwise an error is generated.
If If
.Fl d .Fl d
@ -324,13 +332,14 @@ List all key bindings.
.D1 (alias: Ic ls ) .D1 (alias: Ic ls )
List all sessions managed by the server. List all sessions managed by the server.
.It Xo Ic list-windows .It Xo Ic list-windows
.Op Fl s Ar session-name
.Xc .Xc
.D1 (alias: Ic lsw ) .D1 (alias: Ic lsw )
List all windows. List all windows.
.It Xo Ic new-session .It Xo Ic new-session
.Op Fl d .Op Fl d
.Op Fl s Ar session-name
.Op Fl n Ar window-name .Op Fl n Ar window-name
.Op Fl s Ar session-name
.Op Ar command .Op Ar command
.Xc .Xc
.D1 (alias: Ic new ) .D1 (alias: Ic new )
@ -347,6 +356,7 @@ are the name of and command to execute in the initial window.
.Op Fl d .Op Fl d
.Op Fl i Ar index .Op Fl i Ar index
.Op Fl n Ar name .Op Fl n Ar name
.Op Fl s Ar session-name
.Op Ar command .Op Ar command
.Xc .Xc
.D1 (alias: Ic neww ) .D1 (alias: Ic neww )
@ -378,25 +388,30 @@ New windows will automatically have
added to their environment, but care must be taken not to reset this in shell added to their environment, but care must be taken not to reset this in shell
start-up files. start-up files.
.It Xo Ic next-window .It Xo Ic next-window
.Op Fl s Ar session-name
.Xc .Xc
.D1 (alias: Ic next ) .D1 (alias: Ic next )
Move to the next window in the session. Move to the next window in the session.
.It Xo Ic paste-buffer .It Xo Ic paste-buffer
.Op Fl s Ar session-name
.Xc .Xc
.D1 (alias: Ic paste ) .D1 (alias: Ic paste )
Insert the contents of the paste buffer into the current window. Insert the contents of the paste buffer into the current window.
Ignored unless executed via a key binding. Ignored unless executed via a key binding.
.It Xo Ic previous-window .It Xo Ic previous-window
.Op Fl s Ar session-name
.Xc .Xc
.D1 (alias: Ic prev ) .D1 (alias: Ic prev )
Move to the previous window in the session. Move to the previous window in the session.
.It Xo Ic refresh-client .It Xo Ic refresh-client
.Op Fl c Ar client-tty
.Xc .Xc
.D1 (alias: Ic refresh ) .D1 (alias: Ic refresh )
Refresh the current client if bound to a key, or a single client if one given Refresh the current client if bound to a key, or a single client if one given
with with
.Fl c . .Fl c .
.It Xo Ic rename-session .It Xo Ic rename-session
.Op Fl s Ar session-name
.Ar new-name .Ar new-name
.Xc .Xc
.D1 (alias: Ic rename ) .D1 (alias: Ic rename )
@ -404,6 +419,7 @@ Rename the session to
.Ar new-name . .Ar new-name .
.It Xo Ic rename-window .It Xo Ic rename-window
.Op Fl i Ar index .Op Fl i Ar index
.Op Fl s Ar session-name
.Ar new-name .Ar new-name
.Xc .Xc
.D1 (alias: Ic renamew ) .D1 (alias: Ic renamew )
@ -412,16 +428,19 @@ Rename the current window, or the window at
if specifed, to if specifed, to
.Ar new-name . .Ar new-name .
.It Xo Ic scroll-mode .It Xo Ic scroll-mode
.Op Fl s Ar session-name
.Xc .Xc
Enter scroll mode. Enter scroll mode.
This command works only if bound to a key.
.It Xo Ic select-window .It Xo Ic select-window
.Op Fl s Ar session-name
.Ar index .Ar index
.Xc .Xc
.D1 (alias: Ic selectw ) .D1 (alias: Ic selectw )
Select the window at Select the window at
.Ar index . .Ar index .
.It Xo Ic send-keys Ar key Ar ... .It Xo Ic send-keys
.Op Fl c Ar client-tty
.Ar key Ar ...
.Xc .Xc
Send a key or keys to a window. Send a key or keys to a window.
Each argument Each argument
@ -434,9 +453,9 @@ or
characters. characters.
All the arguments are sent sequentially from first to last. All the arguments are sent sequentially from first to last.
.It Xo Ic send-prefix .It Xo Ic send-prefix
.Op Fl c Ar client-tty
.Xc .Xc
Send the prefix key to a window as if it was pressed. Send the prefix key to a window as if it was pressed.
This is ignored unless bound to a key.
.It Xo Ic set-option .It Xo Ic set-option
.Ar option Ar value .Ar option Ar value
.Xc .Xc
@ -488,7 +507,8 @@ The default is
.Dq exec $SHELL . .Dq exec $SHELL .
.El .El
.It Xo Ic swap-window .It Xo Ic swap-window
.Op Fl i Ar destination-index .Op Fl i Ar index
.Op Fl s Ar session-name
.Ar source-name Ar source-index .Ar source-name Ar source-index
.Xc .Xc
.D1 (alias: Ic swapw ) .D1 (alias: Ic swapw )
@ -496,7 +516,7 @@ This is similar to
.Ic link-window , .Ic link-window ,
except the source and destination windows are swapped. except the source and destination windows are swapped.
It is an error if no window exists at It is an error if no window exists at
.Ar destination-index . .Ar index .
.It Xo Ic unbind-key .It Xo Ic unbind-key
.Ar key .Ar key
.Xc .Xc
@ -505,6 +525,7 @@ Unbind the key bound to
.Ar key . .Ar key .
.It Xo Ic unlink-window .It Xo Ic unlink-window
.Op Fl i Ar index .Op Fl i Ar index
.Op Fl s Ar session-name
.Xc .Xc
.D1 (alias: Ic unlinkw ) .D1 (alias: Ic unlinkw )
Unlink the window at Unlink the window at

4
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.118 2008-06-02 21:08:36 nicm Exp $ */ /* $Id: tmux.h,v 1.119 2008-06-02 21:36:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -766,7 +766,7 @@ extern const struct cmd_entry cmd_unlink_window_entry;
void cmd_select_window_default(void **, int); void cmd_select_window_default(void **, int);
/* cmd-generic.c */ /* cmd-generic.c */
#define CMD_CLIENTONLY_USAGE "[-c client-name]" #define CMD_CLIENTONLY_USAGE "[-c client-tty]"
int cmd_clientonly_parse(struct cmd *, void **, int, char **, char **); int cmd_clientonly_parse(struct cmd *, void **, int, char **, char **);
void cmd_clientonly_exec(void *, struct cmd_ctx *); void cmd_clientonly_exec(void *, struct cmd_ctx *);
void cmd_clientonly_send(void *, struct buffer *); void cmd_clientonly_send(void *, struct buffer *);