mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-23 08:33:17 +01:00
rename-session command.
This commit is contained in:
parent
f92243caa0
commit
16321270c8
6
CHANGES
6
CHANGES
@ -1,3 +1,7 @@
|
||||
09 November 2007
|
||||
|
||||
* (nicm) rename-session command.
|
||||
|
||||
08 November 2007
|
||||
|
||||
* (nicm) Check for required terminal capabilities on start.
|
||||
@ -190,4 +194,4 @@
|
||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||
customisation.
|
||||
|
||||
$Id: CHANGES,v 1.59 2007-11-08 10:39:52 nicm Exp $
|
||||
$Id: CHANGES,v 1.60 2007-11-09 11:02:01 nicm Exp $
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: GNUmakefile,v 1.1 2007-10-31 14:26:26 nicm Exp $
|
||||
# $Id: GNUmakefile,v 1.2 2007-11-09 11:02:01 nicm Exp $
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
@ -20,7 +20,8 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
|
||||
cmd-set-option.c cmd-rename-window.c cmd-select-window.c \
|
||||
cmd-list-windows.c cmd-attach-session.c cmd-send-prefix.c \
|
||||
cmd-refresh-session.c cmd-kill-window.c cmd-list-clients.c \
|
||||
cmd-has-session.c cmd-link-window.c cmd-unlink-window.c cmd-swap-window.c
|
||||
cmd-has-session.c cmd-link-window.c cmd-unlink-window.c \
|
||||
cmd-swap-window.c cmd-rename-session.c
|
||||
|
||||
CC?= gcc
|
||||
INCDIRS+= -I. -I-
|
||||
|
5
Makefile
5
Makefile
@ -1,4 +1,4 @@
|
||||
# $Id: Makefile,v 1.36 2007-10-31 14:26:26 nicm Exp $
|
||||
# $Id: Makefile,v 1.37 2007-11-09 11:02:01 nicm Exp $
|
||||
|
||||
.SUFFIXES: .c .o .y .h
|
||||
.PHONY: clean
|
||||
@ -24,7 +24,8 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
|
||||
cmd-set-option.c cmd-rename-window.c cmd-select-window.c \
|
||||
cmd-list-windows.c cmd-attach-session.c cmd-send-prefix.c \
|
||||
cmd-refresh-session.c cmd-kill-window.c cmd-list-clients.c \
|
||||
cmd-has-session.c cmd-link-window.c cmd-unlink-window.c cmd-swap-window.c
|
||||
cmd-has-session.c cmd-link-window.c cmd-unlink-window.c \
|
||||
cmd-swap-window.c cmd-rename-session.c
|
||||
|
||||
CC?= cc
|
||||
INCDIRS+= -I. -I- -I/usr/local/include
|
||||
|
1
TODO
1
TODO
@ -52,7 +52,6 @@
|
||||
-- For 0.1 --------------------------------------------------------------------
|
||||
- man page
|
||||
- commands:
|
||||
rename sessions
|
||||
kill session (not bound by default)
|
||||
- fix most(1) problems after scrolling
|
||||
- fix mutt problems with redraw (mutt's) status line when reading mail
|
||||
|
126
cmd-rename-session.c
Normal file
126
cmd-rename-session.c
Normal file
@ -0,0 +1,126 @@
|
||||
/* $Id: cmd-rename-session.c,v 1.1 2007-11-09 11:02:01 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* Change session name.
|
||||
*/
|
||||
|
||||
int cmd_rename_session_parse(void **, int, char **, char **);
|
||||
void cmd_rename_session_exec(void *, struct cmd_ctx *);
|
||||
void cmd_rename_session_send(void *, struct buffer *);
|
||||
void cmd_rename_session_recv(void **, struct buffer *);
|
||||
void cmd_rename_session_free(void *);
|
||||
|
||||
struct cmd_rename_session_data {
|
||||
char *newname;
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_rename_session_entry = {
|
||||
"rename-session", "rename", "new-name",
|
||||
0,
|
||||
cmd_rename_session_parse,
|
||||
cmd_rename_session_exec,
|
||||
cmd_rename_session_send,
|
||||
cmd_rename_session_recv,
|
||||
cmd_rename_session_free
|
||||
};
|
||||
|
||||
int
|
||||
cmd_rename_session_parse(void **ptr, int argc, char **argv, char **cause)
|
||||
{
|
||||
struct cmd_rename_session_data *data;
|
||||
int opt;
|
||||
|
||||
*ptr = data = xmalloc(sizeof *data);
|
||||
data->newname = NULL;
|
||||
|
||||
while ((opt = getopt(argc, argv, "")) != EOF) {
|
||||
switch (opt) {
|
||||
default:
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc != 1)
|
||||
goto usage;
|
||||
|
||||
data->newname = xstrdup(argv[0]);
|
||||
|
||||
return (0);
|
||||
|
||||
usage:
|
||||
usage(cause, "%s %s",
|
||||
cmd_rename_session_entry.name, cmd_rename_session_entry.usage);
|
||||
|
||||
cmd_rename_session_free(data);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_rename_session_exec(void *ptr, struct cmd_ctx *ctx)
|
||||
{
|
||||
struct cmd_rename_session_data *data = ptr;
|
||||
struct client *c = ctx->client;
|
||||
struct session *s = ctx->session;
|
||||
|
||||
if (data == NULL)
|
||||
return;
|
||||
|
||||
xfree(s->name);
|
||||
s->name = xstrdup(data->newname);
|
||||
|
||||
if (!(ctx->flags & CMD_KEY))
|
||||
server_write_client(c, MSG_EXIT, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_rename_session_send(void *ptr, struct buffer *b)
|
||||
{
|
||||
struct cmd_rename_session_data *data = ptr;
|
||||
|
||||
buffer_write(b, data, sizeof *data);
|
||||
cmd_send_string(b, data->newname);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_rename_session_recv(void **ptr, struct buffer *b)
|
||||
{
|
||||
struct cmd_rename_session_data *data;
|
||||
|
||||
*ptr = data = xmalloc(sizeof *data);
|
||||
buffer_read(b, data, sizeof *data);
|
||||
data->newname = cmd_recv_string(b);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_rename_session_free(void *ptr)
|
||||
{
|
||||
struct cmd_rename_session_data *data = ptr;
|
||||
|
||||
if (data->newname != NULL)
|
||||
xfree(data->newname);
|
||||
xfree(data);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-rename-window.c,v 1.10 2007-10-30 10:59:43 nicm Exp $ */
|
||||
/* $Id: cmd-rename-window.c,v 1.11 2007-11-09 11:02:01 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -39,7 +39,7 @@ struct cmd_rename_window_data {
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_rename_window_entry = {
|
||||
"rename-window", "renamew", "[-i index] new name",
|
||||
"rename-window", "renamew", "[-i index] new-name",
|
||||
0,
|
||||
cmd_rename_window_parse,
|
||||
cmd_rename_window_exec,
|
||||
|
3
cmd.c
3
cmd.c
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd.c,v 1.24 2007-10-30 11:10:33 nicm Exp $ */
|
||||
/* $Id: cmd.c,v 1.25 2007-11-09 11:02:01 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -40,6 +40,7 @@ const struct cmd_entry *cmd_table[] = {
|
||||
&cmd_next_window_entry,
|
||||
&cmd_previous_window_entry,
|
||||
&cmd_refresh_session_entry,
|
||||
&cmd_rename_session_entry,
|
||||
&cmd_rename_window_entry,
|
||||
&cmd_select_window_entry,
|
||||
&cmd_send_prefix_entry,
|
||||
|
3
tmux.h
3
tmux.h
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.h,v 1.76 2007-10-31 14:26:26 nicm Exp $ */
|
||||
/* $Id: tmux.h,v 1.77 2007-11-09 11:02:01 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -583,6 +583,7 @@ extern const struct cmd_entry cmd_new_window_entry;
|
||||
extern const struct cmd_entry cmd_next_window_entry;
|
||||
extern const struct cmd_entry cmd_previous_window_entry;
|
||||
extern const struct cmd_entry cmd_refresh_session_entry;
|
||||
extern const struct cmd_entry cmd_rename_session_entry;
|
||||
extern const struct cmd_entry cmd_rename_window_entry;
|
||||
extern const struct cmd_entry cmd_select_window_entry;
|
||||
extern const struct cmd_entry cmd_send_prefix_entry;
|
||||
|
Loading…
Reference in New Issue
Block a user