mirror of
https://github.com/tmate-io/tmate.git
synced 2024-12-25 16:19:02 +01:00
Sync OpenBSD patchset 917:
Pass prompts through status_replace so that they can be more helpful (such as showing the previous session name when renaming). From Tiago Cunha.
This commit is contained in:
parent
b2f301f4e2
commit
d256660a78
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-command-prompt.c,v 1.30 2011-01-07 15:04:51 tcunha Exp $ */
|
/* $Id: cmd-command-prompt.c,v 1.31 2011-05-22 16:26:38 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -82,7 +82,7 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
const char *prompts;
|
const char *prompts;
|
||||||
struct cmd_command_prompt_cdata *cdata;
|
struct cmd_command_prompt_cdata *cdata;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
char *prompt, *ptr;
|
char *prompt, *prompt_replaced, *ptr;
|
||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
@ -116,8 +116,12 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ptr = strsep(&cdata->next_prompt, ",");
|
ptr = strsep(&cdata->next_prompt, ",");
|
||||||
if (prompts == NULL)
|
if (prompts == NULL)
|
||||||
prompt = xstrdup(ptr);
|
prompt = xstrdup(ptr);
|
||||||
else
|
else {
|
||||||
xasprintf(&prompt, "%s ", ptr);
|
prompt_replaced = status_replace(c, NULL, NULL, NULL, ptr,
|
||||||
|
time(NULL), 0);
|
||||||
|
xasprintf(&prompt, "%s ", prompt_replaced);
|
||||||
|
xfree(prompt_replaced);
|
||||||
|
}
|
||||||
status_prompt_set(c, prompt, cmd_command_prompt_callback,
|
status_prompt_set(c, prompt, cmd_command_prompt_callback,
|
||||||
cmd_command_prompt_free, cdata, 0);
|
cmd_command_prompt_free, cdata, 0);
|
||||||
xfree(prompt);
|
xfree(prompt);
|
||||||
@ -133,6 +137,7 @@ cmd_command_prompt_callback(void *data, const char *s)
|
|||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmd_ctx ctx;
|
struct cmd_ctx ctx;
|
||||||
char *cause, *newtempl, *prompt, *ptr;
|
char *cause, *newtempl, *prompt, *ptr;
|
||||||
|
char *prompt_replaced;
|
||||||
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
@ -142,8 +147,12 @@ cmd_command_prompt_callback(void *data, const char *s)
|
|||||||
cdata->template = newtempl;
|
cdata->template = newtempl;
|
||||||
|
|
||||||
if ((ptr = strsep(&cdata->next_prompt, ",")) != NULL) {
|
if ((ptr = strsep(&cdata->next_prompt, ",")) != NULL) {
|
||||||
xasprintf(&prompt, "%s ", ptr);
|
prompt_replaced = status_replace(c, NULL, NULL, NULL, ptr,
|
||||||
|
time(NULL), 0);
|
||||||
|
xasprintf(&prompt, "%s ", prompt_replaced);
|
||||||
status_prompt_update(c, prompt);
|
status_prompt_update(c, prompt);
|
||||||
|
|
||||||
|
xfree(prompt_replaced);
|
||||||
xfree(prompt);
|
xfree(prompt);
|
||||||
cdata->idx++;
|
cdata->idx++;
|
||||||
return (1);
|
return (1);
|
||||||
|
11
tmux.1
11
tmux.1
@ -1,4 +1,4 @@
|
|||||||
.\" $Id: tmux.1,v 1.316 2011-05-22 16:26:09 tcunha Exp $
|
.\" $Id: tmux.1,v 1.317 2011-05-22 16:26:38 tcunha Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
.\"
|
.\"
|
||||||
@ -1259,7 +1259,7 @@ The
|
|||||||
.Ar shell-command
|
.Ar shell-command
|
||||||
string may contain the special character sequences supported by the
|
string may contain the special character sequences supported by the
|
||||||
.Ic status-left
|
.Ic status-left
|
||||||
command.
|
option.
|
||||||
If no
|
If no
|
||||||
.Ar shell-command
|
.Ar shell-command
|
||||||
is given, the current pipe (if any) is closed.
|
is given, the current pipe (if any) is closed.
|
||||||
@ -2628,6 +2628,7 @@ Open the command prompt in a client.
|
|||||||
This may be used from inside
|
This may be used from inside
|
||||||
.Nm
|
.Nm
|
||||||
to execute commands interactively.
|
to execute commands interactively.
|
||||||
|
.Pp
|
||||||
If
|
If
|
||||||
.Ar template
|
.Ar template
|
||||||
is specified, it is used as the command.
|
is specified, it is used as the command.
|
||||||
@ -2641,6 +2642,12 @@ a single prompt is displayed, constructed from
|
|||||||
if it is present, or
|
if it is present, or
|
||||||
.Ql \&:
|
.Ql \&:
|
||||||
if not.
|
if not.
|
||||||
|
The
|
||||||
|
.Ar prompts
|
||||||
|
may contain the special character sequences supported by the
|
||||||
|
.Ic status-left
|
||||||
|
option.
|
||||||
|
.Pp
|
||||||
Before the command is executed, the first occurrence of the string
|
Before the command is executed, the first occurrence of the string
|
||||||
.Ql %%
|
.Ql %%
|
||||||
and all occurrences of
|
and all occurrences of
|
||||||
|
Loading…
Reference in New Issue
Block a user