Add an option allow-set-title to forbid applications from changing the

pane title, from someone in GitHub issue 3930.
This commit is contained in:
nicm 2024-04-10 07:36:25 +00:00
parent c62a9ca16b
commit 553d4cba79
4 changed files with 18 additions and 2 deletions

View File

@ -2341,7 +2341,9 @@ input_exit_osc(struct input_ctx *ictx)
switch (option) {
case 0:
case 2:
if (screen_set_title(sctx->s, p) && wp != NULL) {
if (wp != NULL &&
options_get_number(wp->options, "allow-set-title") &&
screen_set_title(sctx->s, p)) {
notify_pane("pane-title-changed", wp);
server_redraw_window_borders(wp->window);
server_status_window(wp->window);

View File

@ -876,6 +876,14 @@ const struct options_table_entry options_table[] = {
"to rename windows."
},
{ .name = "allow-set-title",
.type = OPTIONS_TABLE_FLAG,
.scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE,
.default_num = 1,
.text = "Whether applications are allowed to use the escape sequence "
"to set the pane title."
},
{ .name = "alternate-screen",
.type = OPTIONS_TABLE_FLAG,
.scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE,

6
tmux.1
View File

@ -4750,6 +4750,12 @@ they will be allowed even if the pane is invisible.
Allow programs in the pane to change the window name using a terminal escape
sequence (\eek...\ee\e\e).
.Pp
.It Xo Ic allow-set-title
.Op Ic on | off
.Xc
Allow programs in the pane to change the title using the terminal escape
sequences (\ee]2;...\ee\e\e or \ee]0;...\ee\e\e).
.Pp
.It Xo Ic alternate-screen
.Op Ic on | off
.Xc

2
tmux.h
View File

@ -850,7 +850,7 @@ struct screen_sel;
struct screen_titles;
struct screen {
char *title;
char *path;
char *path;
struct screen_titles *titles;
struct grid *grid; /* grid data */