mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Add option command-prefix which is automatically prepended to any
command (apart from a naked default-shell). The default is "exec ".
This commit is contained in:
parent
1ec4354998
commit
8094e82287
24
names.c
24
names.c
@ -26,8 +26,8 @@
|
|||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
void window_name_callback(unused int, unused short, void *);
|
void window_name_callback(int, short, void *);
|
||||||
char *parse_window_name(const char *);
|
char *parse_window_name(struct window *, const char *);
|
||||||
|
|
||||||
void
|
void
|
||||||
queue_window_name(struct window *w)
|
queue_window_name(struct window *w)
|
||||||
@ -73,9 +73,9 @@ window_name_callback(unused int fd, unused short events, void *data)
|
|||||||
*/
|
*/
|
||||||
if (w->active->cmd != NULL && *w->active->cmd == '\0' &&
|
if (w->active->cmd != NULL && *w->active->cmd == '\0' &&
|
||||||
name != NULL && name[0] == '-' && name[1] != '\0')
|
name != NULL && name[0] == '-' && name[1] != '\0')
|
||||||
wname = parse_window_name(name + 1);
|
wname = parse_window_name(w, name + 1);
|
||||||
else
|
else
|
||||||
wname = parse_window_name(name);
|
wname = parse_window_name(w, name);
|
||||||
free(name);
|
free(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,18 +98,22 @@ default_window_name(struct window *w)
|
|||||||
if (w->active->screen != &w->active->base)
|
if (w->active->screen != &w->active->base)
|
||||||
return (xstrdup("[tmux]"));
|
return (xstrdup("[tmux]"));
|
||||||
if (w->active->cmd != NULL && *w->active->cmd != '\0')
|
if (w->active->cmd != NULL && *w->active->cmd != '\0')
|
||||||
return (parse_window_name(w->active->cmd));
|
return (parse_window_name(w, w->active->cmd));
|
||||||
return (parse_window_name(w->active->shell));
|
return (parse_window_name(w, w->active->shell));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
parse_window_name(const char *in)
|
parse_window_name(struct window *w, const char *in)
|
||||||
{
|
{
|
||||||
char *copy, *name, *ptr;
|
char *copy, *name, *ptr, *prefix;
|
||||||
|
size_t prefixlen;
|
||||||
|
|
||||||
|
prefix = options_get_string(&w->options, "command-prefix");
|
||||||
|
prefixlen = strlen(prefix);
|
||||||
|
|
||||||
name = copy = xstrdup(in);
|
name = copy = xstrdup(in);
|
||||||
if (strncmp(name, "exec ", (sizeof "exec ") - 1) == 0)
|
if (strncmp(name, prefix, prefixlen) == 0)
|
||||||
name = name + (sizeof "exec ") - 1;
|
name = name + prefixlen;
|
||||||
|
|
||||||
while (*name == ' ')
|
while (*name == ' ')
|
||||||
name++;
|
name++;
|
||||||
|
@ -477,7 +477,6 @@ const struct options_table_entry window_options_table[] = {
|
|||||||
.default_num = 1
|
.default_num = 1
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
{ .name = "c0-change-trigger",
|
{ .name = "c0-change-trigger",
|
||||||
.type = OPTIONS_TABLE_NUMBER,
|
.type = OPTIONS_TABLE_NUMBER,
|
||||||
.default_num = 250,
|
.default_num = 250,
|
||||||
@ -503,6 +502,11 @@ const struct options_table_entry window_options_table[] = {
|
|||||||
.default_num = 1
|
.default_num = 1
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ .name = "command-prefix",
|
||||||
|
.type = OPTIONS_TABLE_STRING,
|
||||||
|
.default_str = "exec "
|
||||||
|
},
|
||||||
|
|
||||||
{ .name = "force-height",
|
{ .name = "force-height",
|
||||||
.type = OPTIONS_TABLE_NUMBER,
|
.type = OPTIONS_TABLE_NUMBER,
|
||||||
.minimum = 0,
|
.minimum = 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user