mirror of
https://github.com/tmux/tmux.git
synced 2025-12-17 00:02:23 -05:00
Merge a7baa269b6b2cf85ff0dc38fe000bdc6d7b1d504 into d2c7668bc241a93732229328dc2cebc0df41549f
This commit is contained in:
commit
a12ac6727d
@ -114,6 +114,7 @@ dist_tmux_SOURCES = \
|
|||||||
cmd-pipe-pane.c \
|
cmd-pipe-pane.c \
|
||||||
cmd-queue.c \
|
cmd-queue.c \
|
||||||
cmd-refresh-client.c \
|
cmd-refresh-client.c \
|
||||||
|
cmd-rename-client.c \
|
||||||
cmd-rename-session.c \
|
cmd-rename-session.c \
|
||||||
cmd-rename-window.c \
|
cmd-rename-window.c \
|
||||||
cmd-resize-pane.c \
|
cmd-resize-pane.c \
|
||||||
|
|||||||
79
cmd-rename-client.c
Normal file
79
cmd-rename-client.c
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/* $OpenBSD$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
|
*
|
||||||
|
* 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 <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Change client name.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static enum cmd_retval cmd_rename_client_exec(struct cmd *,
|
||||||
|
struct cmdq_item *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_rename_client_entry = {
|
||||||
|
.name = "rename-client",
|
||||||
|
.alias = "renamec",
|
||||||
|
|
||||||
|
.args = { "c:", 1, 1, NULL },
|
||||||
|
.usage = CMD_TARGET_CLIENT_USAGE " new-name",
|
||||||
|
|
||||||
|
.flags = CMD_CLIENT_CFLAG,
|
||||||
|
.exec = cmd_rename_client_exec
|
||||||
|
};
|
||||||
|
|
||||||
|
static enum cmd_retval
|
||||||
|
cmd_rename_client_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
|
{
|
||||||
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct client *tc = cmdq_get_target_client(item), *c;
|
||||||
|
char *newname, *tmp;
|
||||||
|
|
||||||
|
tmp = format_single_from_target(item, args_string(args, 0));
|
||||||
|
newname = session_check_name(tmp);
|
||||||
|
if (newname == NULL) {
|
||||||
|
cmdq_error(item, "invalid client name: %s", tmp);
|
||||||
|
free(tmp);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
free(tmp);
|
||||||
|
if (strcmp(newname, tc->name) == 0) {
|
||||||
|
free(newname);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
|
if (strcmp(c->name, newname) == 0) {
|
||||||
|
cmdq_error(item, "duplicate client name: %s", newname);
|
||||||
|
free(newname);
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TAILQ_REMOVE(&clients, tc, entry);
|
||||||
|
free(tc->name);
|
||||||
|
tc->name = newname;
|
||||||
|
TAILQ_INSERT_TAIL(&clients, tc, entry);
|
||||||
|
|
||||||
|
notify_client("client-renamed", c);
|
||||||
|
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
2
cmd.c
2
cmd.c
@ -80,6 +80,7 @@ extern const struct cmd_entry cmd_pipe_pane_entry;
|
|||||||
extern const struct cmd_entry cmd_previous_layout_entry;
|
extern const struct cmd_entry cmd_previous_layout_entry;
|
||||||
extern const struct cmd_entry cmd_previous_window_entry;
|
extern const struct cmd_entry cmd_previous_window_entry;
|
||||||
extern const struct cmd_entry cmd_refresh_client_entry;
|
extern const struct cmd_entry cmd_refresh_client_entry;
|
||||||
|
extern const struct cmd_entry cmd_rename_client_entry;
|
||||||
extern const struct cmd_entry cmd_rename_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_rename_window_entry;
|
||||||
extern const struct cmd_entry cmd_resize_pane_entry;
|
extern const struct cmd_entry cmd_resize_pane_entry;
|
||||||
@ -172,6 +173,7 @@ const struct cmd_entry *cmd_table[] = {
|
|||||||
&cmd_previous_layout_entry,
|
&cmd_previous_layout_entry,
|
||||||
&cmd_previous_window_entry,
|
&cmd_previous_window_entry,
|
||||||
&cmd_refresh_client_entry,
|
&cmd_refresh_client_entry,
|
||||||
|
&cmd_rename_client_entry,
|
||||||
&cmd_rename_session_entry,
|
&cmd_rename_session_entry,
|
||||||
&cmd_rename_window_entry,
|
&cmd_rename_window_entry,
|
||||||
&cmd_resize_pane_entry,
|
&cmd_resize_pane_entry,
|
||||||
|
|||||||
15
tmux.1
15
tmux.1
@ -1505,6 +1505,14 @@ See the
|
|||||||
.Ic window-size
|
.Ic window-size
|
||||||
option.
|
option.
|
||||||
.Tg rename
|
.Tg rename
|
||||||
|
.It Xo Ic rename-client
|
||||||
|
.Op Fl c Ar target-client
|
||||||
|
.Ar new-name
|
||||||
|
.Xc
|
||||||
|
.D1 Pq alias: Ic renamec
|
||||||
|
Rename the client to
|
||||||
|
.Ar new-name .
|
||||||
|
.Tg rename
|
||||||
.It Xo Ic rename-session
|
.It Xo Ic rename-session
|
||||||
.Op Fl t Ar target-session
|
.Op Fl t Ar target-session
|
||||||
.Ar new-name
|
.Ar new-name
|
||||||
@ -6487,10 +6495,10 @@ bg=black,fg=default,noreverse
|
|||||||
.Sh NAMES AND TITLES
|
.Sh NAMES AND TITLES
|
||||||
.Nm
|
.Nm
|
||||||
distinguishes between names and titles.
|
distinguishes between names and titles.
|
||||||
Windows and sessions have names, which may be used to specify them in targets
|
Windows, sessions, and clients have names, which may be used to specify them in targets
|
||||||
and are displayed in the status line and various lists: the name is the
|
and are displayed in the status line and various lists: the name is the
|
||||||
.Nm
|
.Nm
|
||||||
identifier for a window or session.
|
identifier for a window, session, or client.
|
||||||
Only panes have titles.
|
Only panes have titles.
|
||||||
A pane's title is typically set by the program running inside the pane using
|
A pane's title is typically set by the program running inside the pane using
|
||||||
an escape sequence (like it would set the
|
an escape sequence (like it would set the
|
||||||
@ -6510,6 +6518,9 @@ A session's name is set with the
|
|||||||
and
|
and
|
||||||
.Ic rename-session
|
.Ic rename-session
|
||||||
commands.
|
commands.
|
||||||
|
A client's name is set automatically at launch and with the
|
||||||
|
.Ic rename-client
|
||||||
|
command.
|
||||||
A window's name is set with one of:
|
A window's name is set with one of:
|
||||||
.Bl -enum -width Ds
|
.Bl -enum -width Ds
|
||||||
.It
|
.It
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user